Windows 7 64 bit multi-core, How to use WMI to get the CPU utilization of each core for a single process?

Dear All,

I'm using Windows 7 64 bit on a laptop, the CPU is i7, 4 cores. When I run the R software, some functions will take a lot of CPU utilization, so I want to record the progress. Could somebody teach me how to use the WMI to get the CPU utilization of each core for a single process? I know how to get the Memory utilization just like :

[code]

Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
Set colObjects = objWMI.ExecQuery("Select * From Win32_Process Where Name = 'Rscript.exe'")

For Each Item in colObjects
    WScript.Echo Item.Name & " - " & Item.WorkingSetSize
Next

[/code]

But about the CPU utilization, I know nothing. Thank you all.

Best Regards,

Sniperhgy

April 28th, 2015 1:59am

Unless the process is written to use multiple CPUs it will use oonly one.  Just get the process data:

Get-Process rscript | select peak*, user*, process*

Use PowerShell.  VBScript cannot do what you want easily.

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 4:43am

Hello jrv,

Thank you for your reply. After run the code, I got a lot of the output messages (I used chrome to run the code) :

PeakPagedMemorySize     : 240377856
PeakPagedMemorySize64   : 240377856
PeakWorkingSet          : 262971392
PeakWorkingSet64        : 262971392
PeakVirtualMemorySize   : 1137569792
PeakVirtualMemorySize64 : 1137569792
UserProcessorTime       : 00:01:04.6624145
ProcessName             : chrome
ProcessorAffinity       : 15

Could you please teach me how to read those messages? BY the way, I don't want the Peak value, the current value should be fine, and how could I calculate the CPU utilization(xx%) via the UserProcessorTime?

Thank you and Best Regards,

Sniperhgy

April 28th, 2015 5:11am

Study the performance monitor.

run "perfmon" and read the help. All of the performance statistics are listed and accessible.

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 5:14am

get-counter '\Process(chrome)\% User Time' -SampleInterval 1 -MaxSamples 10

get-counter -list process |select -expand counter

April 28th, 2015 5:18am

Thank you very much.
Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 5:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics