VB调用PING命令

2025-04-19 08:32:35
推荐回答(1个)
回答1:

下面这个是Ping 的脚本 成功返回true 不成功返回false
Public Function Pings(strMachines As String) As Boolean
aMachines = Split(strMachines, ";")
For Each machine In aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & machine & "'")
For Each objStatus In objPing
If IsNull(objStatus.StatusCode) Or objStatus.StatusCode <> 0 Then
Debug.Print ("machine " & machine & " is not reachable")
Pings = False
Else
Pings = True
End If
Next
Next
End Function
由于现在家用的路由器都是内置http服务的 所以
再配合inet控件(microsoft internet transfer control 6.0)
控制就行了 由于不知道你所用路由器具体的型号和重启页面具体代码 所以就没办法给你编剩下的代码了

有点累了 虽然会弄。。。。。