下面这个是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
ping通就是开机,否则就关机了
温馨提示:答案为网友推荐,仅供参考