H
HankC
This code snippet fails with 'Specified cast is not valid' when running
the query to get application warning events in the last 10 days...
What am I doing wrong?
HankC
Dim objWMIService As Object
objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Dim colEvents As Collection
strquery = "Select * from Win32_NTLogEvent Where Logfile =
'Application' and Type = 'Warning' and TimeWritten >=
'20050916143529.000000-300'"
'''the next line fails: Specified cast is not valid.
colEvents = objWMIService.ExecQuery(strquery, "WQL",
wbemFlagReturnImmediately + wbemFlagForwardOnly)
Dim objEvent As Object
For Each objEvent In colEvents
TextBox1.Text = TextBox1.Text & objEvent.Type & vbVrLf
Next
End If
the query to get application warning events in the last 10 days...
What am I doing wrong?
HankC
Dim objWMIService As Object
objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Dim colEvents As Collection
strquery = "Select * from Win32_NTLogEvent Where Logfile =
'Application' and Type = 'Warning' and TimeWritten >=
'20050916143529.000000-300'"
'''the next line fails: Specified cast is not valid.
colEvents = objWMIService.ExecQuery(strquery, "WQL",
wbemFlagReturnImmediately + wbemFlagForwardOnly)
Dim objEvent As Object
For Each objEvent In colEvents
TextBox1.Text = TextBox1.Text & objEvent.Type & vbVrLf
Next
End If