Google關(guān)鍵詞“WMI CPU使用率”,得到的全是《python使用WMI監(jiān)視系統(tǒng)-CPU使用率》,不用看,肯定又是采集的
Python固然強(qiáng)大,但是調(diào)用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