Re: Is computer connected to network?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 03/03/05


Date: Thu, 03 Mar 2005 09:59:16 +0100

Matthew Bell wrote:

> Using ADSI or WMI or VBScript, what's the most efficient
> way to detect whether an computer is "live" and currently
> connected to the network? I can ping it and scan for the
> results, but I'm guessing that there's a more efficient way
> to do it now via ADSI or WMI. Thanks!
Hi

If you run your script on a Windows XP or Windows 2003 Server, you
can use the WMI class Win32_PingStatus to ping a computer.

http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_pingstatus.asp

For Windows 2000, parsing the output of ping.exe is your best option.

Take a look at the VBScript function IsConnectible in the link below,
it redirects the output of ping.exe to a file and then and looks for
the text "TTL=" to see if the remote computer is online.

http://groups.google.co.uk/groups?selm=Ot9h8JoHFHA.1396%40TK2MSFTNGP10.phx.gbl

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Quantcast