scsvel
13 years agoFrequent Contributor
VBScript - Get CPU Usage
Hi all,
I want to get CPU Usage from VBScript. I can't use TC API that's why I am getting like this. Here is my code.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set AllItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor",,48)
for each itm in AllItems
WScript.Echo itm.PercentProcessorTime & "%"
next
Here PercentProcessorTime gives CPU Time not CPU Usage. I want to get CPU Usage. Can anybody help me?
Refer the screenshot also. Also refer http://msdn.microsoft.com/en-us/library/aa394372(v=VS.85).aspx#methods
Thanks...