Is there any way to get CPU utilization for particular service from a script on Windows? I know wmic cpu get LoadPercentage
will give CPU utilization for the entire system, but is it possible to get it for a particular program like winword.exe?
Yes, it's possible.
This wmic command prints the CPU usage for all processes. Then you can pipe it to findstr
to filter for a particular process (using the flag /c:<process name>
).
wmic path Win32_PerfFormattedData_PerfProc_Process get Name,PercentProcessorTime
Do help findstr
and help find
from the command line to see more ways you can filter the list.
For example:
C:\> wmic path Win32_PerfFormattedData_PerfProc_Process get Name,PercentProcessorTime | findstr /i /c:chrome
chrome 24
chrome#1 0
chrome#2 0
chrome#3 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With