Ok, let me post the entire function... :P
Function GetPingResult$(Host$)
Dim objPing As Object
Dim objStatus As Object
Const timeout$ = "350" ' Timeout Value in ms
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
ExecQuery("Select * from Win32_PingStatus Where Timeout = " & timeout & " AND Address = '" & Host & "'")
'
For Each objStatus In objPing
Select Case objStatus.StatusCode
Case 0: GetPingResult = "Up"
Case 11001: GetPingResult = "Buffer too small"
Case 11002: GetPingResult = "Destination net unreachable"
Case 11003: GetPingResult = "Destination host unreachable"
Case 11004: GetPingResult = "Destination protocol unreachable"
Case 11005: GetPingResult = "Destination port unreachable"
Case 11006: GetPingResult = "No resources"
Case 11007: GetPingResult = "Bad option"
Case 11008: GetPingResult = "Hardware error"
Case 11009: GetPingResult = "Packet too big"
Case 11010: GetPingResult = "Request timed out"
Case 11011: GetPingResult = "Bad request"
Case 11012: GetPingResult = "Bad route"
Case 11013: GetPingResult = "Time-To-Live (TTL) expired transit"
Case 11014: GetPingResult = "Time-To-Live (TTL) expired reassembly"
Case 11015: GetPingResult = "Parameter problem"
Case 11016: GetPingResult = "Source quench"
Case 11017: GetPingResult = "Option too big"
Case 11018: GetPingResult = "Bad destination"
Case 11032: GetPingResult = "Negotiating IPSEC"
Case 11050: GetPingResult = "General failure"
Case Else: GetPingResult = "Unknown host"
End Select
Next
Set objPing = Nothing
End Function
Here is how this is called (just to play with it):
Sub GetIPStatus()
MsgBox "8.8.8.8 : " & GetPingResult("8.8.8.8")
MsgBox "8.8.8.88 : " & GetPingResult("8.8.8.88")
MsgBox "badFQDN.nuts : " & GetPingResult("badFQDN.nuts")
MsgBox "www.google.com : " & GetPingResult("www.google.com")
End Sub
Bookmarks