LoginSignup
0
0

More than 1 year has passed since last update.

指定したIPアドレスに接続されているか確認するVBScript

Posted at
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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0