返回列表 回复 发帖

VBS-利用Win32_PingStatus来ping多台机器

这里ping的是4台机器(atl-dc-01;atl-win2k-01;atl-nt4-01;atl-dc-02)

strMachines = "atl-dc-01;atl-win2k-01;atl-nt4-01;atl-dc-02"
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
            WScript.Echo("machine " & machine & " is not reachable")   
        End If
    Next
Next
感谢Baidu,Google,Dreams8给我这次机会!
还要感谢我的爸爸妈妈!
HOHO
返回列表