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?

- 17,306
- 6
- 61
- 82

- 159
- 1
- 3
- 11
2 Answers
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

- 17,306
- 6
- 61
- 82
-
Indiv, Thank u..I tried but it's not giving me output. I checked for iexplorer but no value is displayed – user1954762 Jan 09 '13 at 08:39
-
Do the wmic command without piping to findstr and see whether it's in the list. If it's in the list, then you should be able to see it when you pipe it to findstr. Capitalization matters unless you pass `/i` to findstr like I did in the example. (and isn't it **iexplore** and not **iexplorer**?) – indiv Jan 09 '13 at 16:14
-
1also see http://stackoverflow.com/questions/2415085/is-it-possible-to-know-the-cpu-utilization-from-command-line – bmeck Jan 25 '13 at 09:33
-
could you make your example (the chrome part) as one line? – Sun May 10 '19 at 18:30
-
@Sun: Fixed it, thanks. – indiv May 13 '19 at 16:58
to do this, the most simple is using MS performance toolkit, it can hire the ETW to track the a lot of metrics include CPU usage. after install performance toolkit (now is in Windows SDK).
execute the following commands:
1. set _NT_SYMBOL_PATH= srv*C:\symbols*http://msdl.microsoft.com/downloads/symbols
2. open trace via: xperf -on base
3. Excute any program for some times.
4. output the result: xperf –d myprofile.etl
5. launch the graphics UI to analysis : xperfview myprofile.etl
unlike WMI, Xperf is a more complex toolkit and can provide more detail in the CPU usage, not only the process, but also the function call consume, CPU state change, and so on. (that is why we import Windows symbols at the first step).
another good point is Xperf hiring ETW, and ETW is little impact to CPU.

- 1,382
- 10
- 14
-
no... i want some command like wmic cpu get loadpercentage similarly to get for a particular process... do you know? – user1954762 Jan 09 '13 at 08:35
-
if what you need is for analysis, you can use WMIC or more directly, using WMI, PowerShell, or taskmgr. – ray_linn Jan 09 '13 at 08:38