how can i check for an empty collection?



i want to check the event log for a specific event id. chances are it wont exist. if it does NOT exist i need to echo "not found" if it does exist i need to echo the date property of the event, but only for the first one found, then i can exit.

i cant for the life of me figure this out. i though maybe colEvents.EOF but that doesnt exist.



intEventCode = 170456
strLog = "Application"
strComputer = "xpvirtual01"
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colEvents = objWMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = '" & strLog & "' and EventCode = " & intEventCode)

if a single event 170456 was found
echo event.date
Else
echo no events found
end if

i know ill probably need a for each loop, or is there a way to only return 1 event from the query? like a SELECT TOP 1 or something?

thanks

.



Relevant Pages

  • Re: Service will not start after a reboot
    ... and the whole point of writing it as a service was to ... clues in the Event log and there are no dependencies on other services. ... Use the Task Scheduler to run the following batch file at boot ... echo %date% %time%>>c:\Waldy.log ...
    (microsoft.public.windowsxp.general)
  • Re: event logs
    ... I use task scheduler to run it and email it to me from the server. ... @echo off ... P.S. Dumpel does not export the DNS event log. ...
    (microsoft.public.win2000.security)
  • Windows event log event not being emailed
    ... event is seen in Nagios event log, ... nagios server service definition is below: ... @echo off ... echo Anhalten und Deinstallieren des Service "eventlog_agent" ...
    (RedHat)
  • Re: hmm... rand
    ... I can echo that timereturns current time and thus wont ... your computer clock never changes... ... a mersenne twister is top notch stuff for roguelikes and can be ...
    (rec.games.roguelike.development)
  • Re: getting values from www
    ... This looks like you are trying to create something to steal someone elses ... you probably wont find anyone to help you. ... > interesting me infos from WWW. for example i have URL like ... > echo $txt; ...
    (alt.php)