Hi guys I have a problem whereby I'm making a wmi query to around 500 servers. For the most part a connection is made without a problem. However I've got one or two servers that hang at the point of connecting to the WMI service on the machine.
I've tried error trapping (see below)and now I'm really stuck, as I reckon the script neither makes or is refused a connection hence the error trapping does not work.
I guess my question is if there is a way to say give a machine say 5 seconds to respond and if it doesn't assume a connection can't be made and the script goes onto the next machine.
Anycase, enough of my rambling, here is the code snippet I'm using..
I've tried error trapping (see below)and now I'm really stuck, as I reckon the script neither makes or is refused a connection hence the error trapping does not work.
I guess my question is if there is a way to say give a machine say 5 seconds to respond and if it doesn't assume a connection can't be made and the script goes onto the next machine.
Anycase, enough of my rambling, here is the code snippet I'm using..
Code:
strComputer="computerA"
Call getServices(strComputer)
Sub getServices (strComputer)
bolName=False
bolFlag=False
Err.Number=0
WScript.Echo strComputer
WScript.Echo "=============="
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
it is at this point the script is hanging and never gets to the next line to test the error number.
If Err.Number<>0 Then
WScript.Echo "Machine could not be contacted. Please check manually"
Else
Wscript.Echo "Machine contacted"
End If
End Sub