|
Function zGen_Ping(sHost)
'This function checks that you can get through to the host you require
'Example usage:
' 'Check we have internet...
' If Not zGen_Ping("www.google.com") Then
' Msgbox "Not connected to Internet",vbCritical,"Fatal Error:"
' Call ExitTest()
' End If
Print "Gen_Ping : " & sHost
Dim oPing, oRetStatus
Set oPing = GetObject("winmgmts:").ExecQuery ("select * from Win32_PingStatus where address = '" & sHost & "'")
For Each oRetStatus In oPing
If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
Print "Gen_Ping Failed - Status code :" & oRetStatus.StatusCode
zGen_Ping = False
Else
Print "Gen_Ping OK - Bytes : " & vbTab & oRetStatus.BufferSize
Print "Gen_Ping OK - Time(ms) : " & vbTab & oRetStatus.ResponseTime
Print "Gen_Ping OK - TTL(s) : " & vbTab & oRetStatus.ResponseTimeToLive
zGen_Ping = True
End If
Next
Set oPing = Nothing
End Function |
|