VBS通过WMI获取CPU使用率的代码
程序员文章站
2022-04-10 08:13:20
python固然强大,但是调用wmi还是用vbs比较“正宗”。 复制代码 代码如下: on error resume next strcomputer = "." set...
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
原文:http://demon.tw/programming/vbs-wmi-cpu-usage.html