I found this VB Script that works well on terminal servers. I just cant remember where I got it. you may need to straighten it out a little cut and paste didn't do a job of keeping it formated.
'****************************************************
'*** This script depends on 2 things to work one is that ***
'*** there is a p:\userlog directory (p is the system ***
'*** Which can be changed by editing the AuditFile= line ***
'*** the other is that you MUST go in to the MMC on the ***
'*** Win2k Server open GroupPolicy on the local computer ***
'*** Goto User Configuration -> Logon/logoff scripts and ***
'*** Put the Scripts in there One for login and the
'***
'*** one for Logoff (the only difference is the
'***
'*** F.Writeline. The login script writes Login: etc
'***
'*** and the logoff writes logoff: etc. If the file
'***
'*** doesnt exist it writes a new one. You could also ***
'*** Pipe this info into a db if you would like as well
'***
'*** ENJOY!!!
'***
'****************************************************
Set WSHNetwork = WScript.CreateObject("WScript.Network")
' Get Current Users Information
set shell = WScript.CreateObject( "WScript.Shell" )
username = shell.ExpandEnvironmentStrings("%USERNAME%")
clientmachine = shell.ExpandEnvironmentStrings("%CLIENTNAME%")
sessionname = shell.ExpandEnvironmentStrings("%SESSIONNAME%")
server = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
AuditFile = "C:\userlog\" & username & ".log"
Const forReading = 1
Const ForWriting = 2
Const ForAppending = 8
CRLF = CHR(10) & CHR(13)
set fs = CreateObject("Scripting.FilesystemObject")
' Check for Audit file
if (fs.FileExists(AuditFile)) Then
' Create the token file and write information
set f = fs.OpenTextFile (AuditFile, ForAppending, True)
f.WriteLine "LogIn: " & username & "," & clientmachine & "," & sessionname & "," & server & "," & Date & " " & Time
f.Close
Else
' Create the token file and write information
fs.CreateTextFile(AuditFile)
set f = fs.OpenTextFile (AuditFile, ForAppending, True)
f.WriteLine "LogIn: " & username & "," & clientmachine & "," & sessionname & "," & server & "," & Date & " " & Time
f.Close
end if