If the query is written correctly it will not fail, it is returning nothing,
basically an empty collection. You can check the Count on "wmiobj", if it
is equal to 0 then you can go ahead an set it to null.
Thanks,
Jonathan
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--
"pantagruel" <rasmussen.bryan@gmail.com> wrote in message
news:bccfc8b1-85fc-4907-b3bc-0bf5b98f6f43@d2g2000pra.googlegroups.com...
> Hi,
>
> I have the following:
>
> try{
>
> wmiobj = locmachine.ExecQuery("Select * from Win32_NTLogEvent Where
> Logfile = 'Security' And TimeWritten >= '" + dtmStartDate + "' and
> TimeWritten < '" + dtmEndDate + "'");
> }catch(err){
> wmiobj=null;
> }
> WScript.Echo(String(wmiobj));
>
> running as a WSF JavaScript, unfortunately when I run it and the query
> doesn't return anything it doesn't raise an error, so wmiobj does not
> get set to null
>
> How do I set it to null if the query does not provide a usable return?
>