GetPingStatus.vbs
'// GetPingStatus("IPアドレス")か、GetPingStatus("コンピュータ名")で、
'// Trueが返ってくれば疎通OK
Function GetPingStatus(ByVal ip_address)
Dim query, wmi
query = "SELECT * FROM Win32_PingStatus WHERE Address = '" & ip_address & "'"
GetPingStatus = False
For Each wmi In GetObject("winmgmts:\\.\root\cimv2").ExecQuery(query, , &H30)
If wmi.StatusCode = 0 Then GetPingStatus = True: Exit For
Next
End Function
'// テスト結果
If GetPingStatus("192.168.20.11") Then
Msgbox "接続されています。"
Else
Msgbox "接続されていません。"
End If