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 off                              if \{%1\}==\{\} @echo Syntax: LogonDtTm LT&goto :EOF                              setlocal                              set lt=0                              for /f "Tokens=1-3" %%a in ('psloggedon -l^|find /i "%USERDOMAIN%\%UserName%"') do (                               set lt=%%a %%b                              )                              endlocal&set %1=%lt%