VulcanJedi
Technical User
I have the following lines of code:
the issue is when colleggedEvents is empty and in nothing is returned from the query than the for each loop crashes; is there a way to capture if the query is empty??
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and " _
& "EventCode = '1106' and Type = 'error'")
For Each objevent In colLoggedEvents
Tranpkp ![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)
the issue is when colleggedEvents is empty and in nothing is returned from the query than the for each loop crashes; is there a way to capture if the query is empty??
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and " _
& "EventCode = '1106' and Type = 'error'")
For Each objevent In colLoggedEvents
![[yinyang] [yinyang] [yinyang]](/data/assets/smilies/yinyang.gif)
![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)