- Dim WebAddress
- WebAddress=InputBox("请输入你要ping的网络地址","ping a computer without using ping.exe","www.google.cn")
- If WebAddress <> "" Then
- Set OBJWMIService = GetObject("winmgmts:\\.\root\cimv2")
- Set colPings = OBJWMIService.ExecQuery("Select * From Win32_PingStatus Where Address = '" &WebAddress& "'")
- For Each OBJStatus in colPings
- If IsNull(OBJStatus.StatusCode) Or OBJStatus.StatusCode <> 0 Then
- WScript.Echo "Computer did not respond."
- Else
- MsgBox "pinging [" &WebAddress& "] one time with "&OBJStatus.BufferSize& "bytes of data:" &chr(10)&chr(10)& "Reply from " &OBJStatus.ProtocolAddress& ": bytes=" &OBJStatus.BufferSize& " time="&OBJStatus.ResponseTime& "ms TTL="&OBJStatus.ResponseTimeToLive
- End If
- Next
- End If
复制代码
|