Ping – How to Determine if a Machine is Online Without Using Ping

ping

I used to use an application that could ping or maybe run a port scan on a machine even if the machine was configured to not allow it.

I am currently trying to ping a remote machine on our WAN, but I have configured the machine to not allow ping. Is there something similar to ping that I can use?

Again, this a machine located in another city that is part of our wan.

Best Answer

If your using XP/2003+ (this includes Vista/2008/7), then you can use the Win32_PingStatus. The machines inwhich is running the script code is the only system which needs to be XP/2003+, and it works just like using Ping.exe, only it's not using ping.exe so it should act as a loophole to your security setting which does not allow the execution of ping.exe.

strComputer = "192.168.1.1"
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_PingStatus " & _
        "Where Address = '" & strComputer & "'")
For Each objItem in colItems
    If objItem.StatusCode = 0 Then 
        WScript.Echo "Reply received."          
    End If
Next

See the Scripting Guy article for more info on how to use Win32_PingStatus:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0914.mspx

Related Topic