Home  >  Article  >  Web Front-end  >  How to get CPU usage in VBScript

How to get CPU usage in VBScript

高洛峰
高洛峰Original
2017-01-16 10:35:281778browse

VBScript通过WMI获取CPU使用率的代码

度娘中,搜索关键词“WMI CPU使用率”,得到的全是《python使用WMI监视系统-CPU使用率》,不用看,肯定又是采集的。

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

以上所述就是本文的全部内容了,希望大家能够喜欢。

更多VBScript获取CPU使用率的方法相关文章请关注PHP中文网!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn