Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBscript - Test that WMI exists before attempting to connect/query

$
0
0

Hi, I have a script that loads a list of our servers or computers from an OU in Active Directory, then checks each system to ensure several services are running. I am running into a problem where my script completely hangs when it attempts to connect to WMI on remote systems that are not Windows systems (ie: Linux appliances), or have broken WMI.

I use the following code to query WMI for the list of running processes on the computer:

Set ProcessList=GetObject("winmgmts://"&sCompName).InstancesOf("win32_process")

But if I try to run that line against a Linux email appliance, my script just hangs up and never continues, no error is produced. On Error Resume Next has no effect.

Is there a way that I can check if a WMI connection is even possible BEFORE atempting to actually connect? I have done a lot of Google searches, and have not found anything so far.

Thanks in advance for your help!



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>