Saturday, 25 February 2012

Maintain a log file of logons and logoffs

Step 1: Create the following two files using Notepad : 

------logon script----
echo logon %username% %computername% %date% %time% >> \\server\share\logon.txt

-----logoff script-----
echo logoff %username% %computername% %date% %time% >> \\server\share\logoff.txt

and save them as batch file (add ".bat" ext).

Step 2: Make a folder named "share" on the server and share it.

Step 3: Update Group Policy to run the appropriate batch file.
              In Group Policy, go to:
             User Configuration-> Windows Settings-> Scripts (Logon/Logoff)-> Logon
              and add logon.bat file.

             Similarly, add the logoff.bat file.

Step 4: As users log on and off, your log file should look something like this:


logon jake comp1 Tue 22/02/2005 10:39:51.12
logoff ron comp2 Tue 22/02/2005 10:41:08.45


* make sure that the batch scripts should have the desired permissions for the domain users for the scripts to run.

1 comment: