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

随机文章:

  1. DOSLNK.EXE下载
  2. 用VBS处理二进制文件的实例
  3. 用C语言屏蔽键盘和鼠标
  4. WMI工具:WMI Event Viewer
  5. Ubuntu下安装Lighttpd+PHP+MySQL

留下回复