Deep BlueVBScriptWMIPHPC语言JavaScriptWindows API路由器Windows函数Python

WMI中的Win32_PingStatus类

平时很少用到ping命令,所以这个类也没怎么用过,测试了一下,好像效率比ping要高。计算ping 100次demon.tw延迟的平均值。

IP = "demon.tw"
WQL = "Select * from Win32_PingStatus Where Address = '$IP'"
WQL = Replace(WQL,"$IP",IP)
n = 0 : s = 0
Do Until n = 100
    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set colItems = objWMIService.ExecQuery(WQL,,48)
    For Each objItem in colItems
        If objItem.StatusCode = 0 Then
            s = s + objItem.ResponseTime
            n = n + 1
        End If
    Next
Loop
WScript.Echo "Average:" & s / n

参考链接:Win32_PingStatus Class


http://ken.gw.to/