#146155 - 2005-08-22 06:48 PM
Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
I would like to track when users log off their workstations. I have created this script but it doesn't seem to be working. Do I first need a command to create the log file if it doesn't exist? I tried creating a log file manaully and that didn't work either.
$logfile = "\\servername\userlogs$\@USERID.log" $logfile = WRITELINE("LOGOFF ;"+@DATE+";"+@TIME+";"+@USERID+";"+@WKSTA+@CRLF)
|
|
Top
|
|
|
|
#146157 - 2005-08-22 08:04 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
I don't get what that filehandle parameter is for. Kixtart command reference doesn't explain it. Would I do something like this then?
$logfile = "\\servername\@USERID.log" Open(1, $logfile, 1) $logfile = WRITELINE("LOGOFF ;"+@DATE+";"+@TIME+";"+@USERID+";"+@WKSTA+@CRLF)
And would I also need a .bat file that calls the kixtart script like this:
kix32.exe logoff.kix
Edited by hywaydave (2005-08-22 08:04 PM)
|
|
Top
|
|
|
|
#146160 - 2005-08-22 08:14 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
could you please be a little more clearer? What am I suppose to do with $RC? This script is not working and the permissions on that folder are correct. I even tried this:
$logfile = Open(1, "\\servername\userlogs$\@USERID.log", 1) $logfile = WRITELINE("LOGOFF ;"+@DATE+";"+@TIME+";"+@USERID+";"+@WKSTA+@CRLF)
According to Kixtart, the mode should be a 1 instead of a 5. 1 If the file does not exist, Open( ) will create a new file.
|
|
Top
|
|
|
|
#146162 - 2005-08-22 08:33 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
I'm not arguing, I just want to make sure I'm on the right track. I appreciate your help a lot. I'll try using the 5 for my mode.
|
|
Top
|
|
|
|
#146164 - 2005-08-22 09:01 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
Thanks.
My next question. I want this to run when the user logs off. So I created a GPO and in the logoff script properties I specified the logoff.bat file, which will be located in: \\domainname.com\SysVol\domainname.com\Policies\{AD4DEG97-AS8C-4470-B8C8-2E13B477245V}\User\Scripts\Logoff
I have the kix32.exe and my logoff.kix script (which we worked on above) in this directory too. The logoff.bat file reads:
kix32.exe logoff.kix
I receive this error when it's ran. ERROR: failed to find/open script [logoff.kix]!
|
|
Top
|
|
|
|
#146166 - 2005-08-22 09:53 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
.
|
|
Top
|
|
|
|
#146167 - 2005-08-22 10:02 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
OK, maybe it's not working yet. I can run the logoff.bat file from command line and it'll create or update the log file, but when I logoff Windows will say "running logoff scripts" but it doesn't create the file.
|
|
Top
|
|
|
|
#146168 - 2005-08-22 10:35 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
Will the @USERID work in a logoff script?
|
|
Top
|
|
|
|
#146170 - 2005-08-22 10:44 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
I even took out the @userid part and just tried to have the logoff script create a test.txt file and it never did. Although when I logoff, Windows says "running logoff scripts".
|
|
Top
|
|
|
|
#146171 - 2005-08-22 10:47 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
Tried using %username% and had the same results.
|
|
Top
|
|
|
|
#146173 - 2005-08-23 02:53 PM
Re: Help with script to track logoff times
|
hywaydave
Fresh Scripter
Registered: 2005-07-20
Posts: 26
|
This is for Human Resources to look at and they want to be able to look at a log at any given time for any given employee without me having to run a script with a specific date. So does anyone have an idea as to why this logoff script won't work from the logoff GPO but it'll work just fine when I just run the batch file from command line?
|
|
Top
|
|
|
|
#146174 - 2005-08-23 03:31 PM
Re: Help with script to track logoff times
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Just a quick plug...
You can use fnDateTime() to get a properly formatted date string localized for your timezone.
Code:
fnDateTime("1-Aug-2005",3)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 565 anonymous users online.
|
|
|