oops! I spoke too soon. The script actually writes all
the times for the events it pulls from the eventlog 6 hours
behind the correct time. I have checked to make sure that
the computers (yes, I have tested the script on 2 xp
machines) have the same time settings which are for the
same correct time zone, they are both set to correct for
daylight savings time (the script has the same problem even
if they are set not to correct for day light savings time)
and both machines show the correct time in the task bar.
The event logs on both machines give the correct time for
the events, so it must be the script. The script also uses
the now() command to report the time the script was written
and now() reports the correct time. I have listed the
script and some example output from it below. Please let
me know if you see anything out of place. Thanks!
Script:
Set objFS = CreateObject("Scripting.FileSystemObject")
'Open logfile. True means Overwrite any old file
Set objLogFile =
objFS.CreateTextFile("d:\watch\when_on.log", True)
'Write to log file
objLogFile.WriteLine("Log started at " & now() )
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'System'
and " _
& "EventCode = '6005' or EventCode = '6006'")
for each objevent in colloggedevents
Dim wConvDate
Set wConvDate = CreateObject("WbemScripting.SWbemDateTime")
wConvDate.Value = objevent.timewritten
objLogFile.WriteLine(wConvDate.GetVarDate & ": " &
objevent.message )
next
Output:
Log started at 11/12/2004 9:26:09 PM
11/12/2004 3:24:22 PM: The Event log service was started.
11/12/2004 3:23:16 PM: The Event log service was stopped.
10/31/2004 2:17:29 PM: The Event log service was started.
10/26/2004 5:10:47 PM: The Event log service was started.
10/26/2004 5:06:54 PM: The Event log service was stopped.
-----Original Message-----
Thanks so much everyone for your replies! It works great
now! I am very appreciative of all the help I receive
here from the experts like you.
