It seems my function to detect and report errors doesn't work.
After any given
[code]set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive",,48)[/code]
I call
[code]error_returned = Err.Number : if error_returned <> 0 then wscript.echo check_wbem_error(error_returned) end if[/code]
which calls the function
[code]function check_wbem_error(error)
if error = 2147749891 then check_wbem_error = "wbemErrAccessDenied - Current user does not have the permission to view the result set."
if error = 2147749889 then check_wbem_error = "wbemErrFailed - Unspecified error."
if error = 2147749896 then check_wbem_error = "wbemErrInvalidParameter - Invalid parameter was specified."
if error = 2147749911 then check_wbem_error = "wbemErrInvalidQuery - Query syntax is not valid."
if error = 2147749912 then check_wbem_error = "wbemErrInvalidQueryType - Requested query language is not supported."
if error = 2147749894 then check_wbem_error = "wbemErrOutOfMemory - Not enough memory to complete the operation."
end function[/code]
Any ideas?
IE - If I replace Win32_CDROMDrive with Win32_CDROMDrive1, it doesn't throw an error where expected. Same if I replace Select * with a list of (bad) atttributes. That line actually runs and err.number is still 0 - so my function doesn't detect the error. Try and enumerate the returned collection though and of course an error is thrown - but by cscript and not my function. Nasty. any ideas? anyone, anyone, Bueller, Bueller???