Useful Tech Tips, Tutorials and guides

Audit users with a batch file

Audit users Logon/logoff as well as Startup/Shutdown with batch file

Here are four simple Batch files you can use to audit your users logon/logoff as well as startup/shutdown activity. to install simply create the following four batch files. you can either use the startup folder in windows if you dont use Active Directory or I would suggest using Logon/Logoff shutdown/startup scripts in Group Policy.

Login.bat

for /f “Tokens=2 Delims=[]” %%i in (‘ping -n 1 “%computername%”‘) do set IP=%%i

echo %username% logged ON %computername%, IP=%IP% @ %time% %date% >> \serveraudits$users%username%.txt

Logoff.bat

echo %username% logged OFF %computername% @ %time% %date% >> \vtjnbdc02audits$users%username%.txt

Startup.bat

for /f “Tokens=2 Delims=[]” %%i in (‘ping -n 1 “%computername%”‘) do set IP=%%i
echo Started up, IP=%IP% @ %time% %date% >> \serveraudits$computers%computername%.txt

Shutdown.bat

echo Shutdown @ %time% %date% >> \vtjnbdc02audits$computers%computername%.txt