VBS通过WMI获取CPU使用率的代码
(编辑:jimmy 日期: 2024/11/15 浏览:3 次 )
Python固然强大,但是调用WMI还是用VBS比较“正宗”。
复制代码 代码如下:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
For Each objItem in colItems
WScript.Echo "LoadPercentage: " & objItem.LoadPercentage
Next
原文:http://demon.tw/programming/vbs-wmi-cpu-usage.html
复制代码 代码如下:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
For Each objItem in colItems
WScript.Echo "LoadPercentage: " & objItem.LoadPercentage
Next
参考链接:Win32_Processor Class
原文:http://demon.tw/programming/vbs-wmi-cpu-usage.html
下一篇:vbs 注册表操作类代码