Hi Guys, Can anyone help with a weird prob I am having. First the code:
Set objWMIServer = GetObject("WinMgmts:{ImpersonationLevel=Impersonate}!\\" & strServer & "\root\CIMV2") If Err.Number <> 0 Then Call subErrors Exit For End If Set objWMIRegistry = GetObject("WinMgmts:{ImpersonationLevel=Impersonate}!\\" & strServer & "\root\default:StdRegProv") If Err.Number <> 0 Then Call subErrors Exit For End If
Forget the "Exit For's" as this is within a For loop, but basically this works fine, and works reliably on nearly every server, apart from a few. I check with a WMI ping prior to attempting the WMI getobject too. What happens is that the server doesnt actually fail to respond or crash the script, (I have used the on error etc) but the script just seems to "wait" at the first getobject. It happens regularly with certain servers, and I just cant figure why. I CAN connect using WMI Browsers etc, and that seems fine, so I know perms are OK. Is there any way to force a WMI query to somehow "timeout" if the server is queried but doesnt answer?
Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You could try using swbemlocator...it only has two timeout (none and 2 min)...the following should be 2 min though if WMI is corrupted on the machine....it won't help either.