Question Locked

Beginner needs to do logon script in group policy

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Can someone help me write a script? I need to track logon/off times & dates. Here's what I know... I've seen some examples of what to put in notepad & save as a .bat file. Then, I know to go to group policy, & add it to the logon script. But then what? I don't know if the script was written correctly or how to retrieve the results (I've never done this before).

2 replies

by ole.kirk

Log user logon/logoff
First you have to make a .cmd or .bat file
this is my userlog.bat make one and save it
*******************************************
@echo off
rem Environment changes made after SETLOCAL has been issued are local to the batch file.
rem Environment changes made after ENDLOCAL has been issued are global to the system.
rem ~0,8% uses the first 8 caracters of the timestamp
rem %* is a command line var i use logon and logoff
SETLOCAL
set logtime=%TIME:~0,8%
ECHO %computername%;%username%;%DATE%;%logtime%;%*>>c:\userlog.csv
ENDLOCAL
exit
*******************************************
Start the Group Policy Editor (gpedit.msc)
and go to Computer Configuration\Windows Settings\Scripts (startup/Shutdown).
To add a script, double-click the entry "shutdown" in the right pane.
In the new window klik add...
In the new window klik Browse...
Browse to the file that you wish to add
then add script Parameters: LogOff
klik OK

This discussion is closed to new replies.