Reputation: 555
I have a vbScript which I use to stop, start and restart services. It works but I have one little niggle. I hoped to be able to watch for the Service State change events (7036) in the Event log by
StartTime=CDate(Now())
.... service stop/start commands etc
Set colServiceEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent " _
& "Where Logfile = 'System'" _
& " and EventCode = '7036'" _
& " and TimeWritten >'" & StartTime & "'" )
By fiddling the StartTime I can see 7036 Events in the last few minutes but I can't seem to see service state change events within the life of the script. Am I missing something or this a windows "feature"?
To be clear the script works and I can verify the status by query on Win32_Service but I'd like to know for future reference.
"There's more than 1 way to skin a cat in vbscript but most of them seem to involve a chain gun and a mincer"
Upvotes: 0
Views: 196
Reputation: 16950
I guess the issue is related to the date-time values.
Look at the article (especially part Converting VBScript dates to WMI Dates
) from : http://www.aspfree.com/c/a/Windows-Scripting/Working-with-Dates-in-WMI/
Upvotes: 1