'---------------------------------------
' Script to track logon and logoff events
' 1 03.June.2010 robber
''''''''''''''''''''''''''''''''''
' Constants for opening files
''''''''''''''''''''''''''''''''''
Const OpenFileForReading = 1
Const OpenFileForWriting = 2
Const OpenFileForAppending = 8
dim a, src , sVers
dim fs
'--- set up files & log ---------
'change to suit domain setup... the sysvol area can be written to by startup & logon scripts
const LogFldr="\\SBSSERVER\SYSVOL\mydomain\logs\"
lf = "logonevents.csv"
actionX = WScript.Arguments(0) 'assume the first argument is the action being performed'
sVers=""
'configure a consistent , orderable date time YYYYMMDD-HHNN
datetime=Year(now()) & Right("0" & Month(now()), 2) & Right("0" & Day(now()), 2) & "-" & Right("0" & Hour(now()), 2) & Right("0" & Minute(now()), 2) '& Right("0" & Second(now()), 2)
'or use a date format Xcel will convert to DateTime value
'configure a consistent , convertable date time YYYYMMMDD-HHNN
datetime=Year(now()) & MonthName(Month(now()),True) & Right("0" & Day(now()), 2) & "-" & Right("0" & Hour(now()), 2) & Right("0" & Minute(now()), 2) '& Right("0" & Second(now()), 2)
' Create the Shell etc objects
Set oShell = CreateObject("WScript.Shell")
Set oNet = CreateObject("WScript.Network")
Set oFSO = CreateObject("Scripting.FileSystemObject")
' write to Log
Set flf = oFSO.GetFile(logfldr & lf)
Set tslf = flf.OpenAsTextStream(OpenFileForAppending)
tslf.WriteLine ( onet.UserName & " , " & Onet.ComputerName & " , " & WeekdayName(Weekday(Now)) & " , " & Datetime & " , " & ActionX)
tslf.Close
'------ end ---
set onet = nothing
set oShell = nothing
Set oFSO = Nothing
wscript.quit
|