PingHost.vbs |
Option Explicit
If Ping("127.0.0.1") Then
MsgBox("Host Responded to Ping.")
Else
MsgBox("Ping Failed!")
End If
wscript.quit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''' Subs / Classes / Functions '''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function Ping(strHost)
' The Function simply returns a True or False boolean vaule.
' For the original example file for this function and other interesting scripts
' goto www.RichSchreiber.com
Dim oPing, oStatus
Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
ExecQuery("select * from Win32_PingStatus where address='" & strHost & "'")
For Each oStatus In oPing
If IsNull(oStatus.StatusCode) Or oStatus.StatusCode <> 0 Then
Ping = False
Else
Ping = True
End If
Set oStatus = Nothing
Next
Set oPing = Nothing
End Function