ユーザーが選択したサーバー IP に対して簡単な PING を実行して、到達可能であることを確認しています。
次のコードは、必要なことを正確に実行しますが、コマンド シェル ウィンドウのクイック フラッシュを回避したい場合を除きます。
その厄介な CMD ウィンドウを最小化するには、何を変更する必要がありますか?
SystemReachable (myIP)
If InStr(myStatus, "Reply") > 0 Then
' IP is Confirmed Reachable
Else
' IP is Not Reachable
End If
''''''''''''''''''''''
Function SystemReachable(ByVal strIP As String)
Dim oShell, oExec As Variant
Dim strText, strCmd As String
strText = ""
strCmd = "ping -n 1 -w 1000 " & strIP
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec(strCmd)
Do While Not oExec.StdOut.AtEndOfStream
strText = oExec.StdOut.ReadLine()
If InStr(strText, "Reply") > 0 Then
myStatus = strText
Exit Do
Else
myStatus = ""
End If
Loop
End Function