Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
November 9, 2006
I previously scripted LogonTime.bat to set a variable to the current user's logon date and time.
Using PsLoggedOn.exe, I have scripted LogonDtTm.bat to perform the same task.
The syntax for using LogonDtTm.bat is:
[call] LogonDtTm LT
Where LT is a call directed environment variable that will contain the date and time of the current user's logon, like MM/DD/YYYY HH:MM:SS.
LogonDtTm.bat contains:
@echo offif {%1}=={} @echo Syntax: LogonDtTm LT&goto :EOFsetlocalset lt=0for /f "Tokens=1-3" %%a in ('psloggedon -l^|find /i "%USERDOMAIN%%UserName%"') do ( set lt=%%a %%b)endlocal&set %1=%lt%
You May Also Like