C:\> wmic cpu get loadpercentage
LoadPercentage
0
Or
C:\> @for /f "skip=1" %p in ('wmic cpu get loadpercentage') do @echo %p%
4%
Answer from Alex K. on Stack OverflowC:\> wmic cpu get loadpercentage
LoadPercentage
0
Or
C:\> @for /f "skip=1" %p in ('wmic cpu get loadpercentage') do @echo %p%
4%
The following works correctly on Windows 7 Ultimate from an elevated command prompt:
C:\Windows\system32>typeperf "\Processor(_Total)\% Processor Time"
"(PDH-CSV 4.0)","\\vm\Processor(_Total)\% Processor Time"
"02/01/2012 14:10:59.361","0.648721"
"02/01/2012 14:11:00.362","2.986384"
"02/01/2012 14:11:01.364","0.000000"
"02/01/2012 14:11:02.366","0.000000"
"02/01/2012 14:11:03.367","1.038332"
The command completed successfully.
C:\Windows\system32>
Or for a snapshot:
C:\Windows\system32>wmic cpu get loadpercentage
LoadPercentage
8
You can use the tool typeperf.
To list all processes:
typeperf "\Process(*)\% Processor Time" -sc 1
List all processes, take 5 samples at 10 second intervals:
typeperf "\Process(*)\% Processor Time" -si 10 -sc 5
If you want a specific process, node for example:
typeperf "\Process(node)\% Processor Time" -si 10 -sc 5
You also can dump it to a csv file and filter in a spreadsheet to remotely diagnose issues.
The following gives me 5 minutes (at 10 second intervals) of all processes. The data includes not just % Processor Time, but IO, memory, paging, etc.
typeperf -qx "\Process" > config.txt
typeperf -cf config.txt -o perf.csv -f CSV -y -si 10 -sc 60
More info: https://technet.microsoft.com/en-us/library/bb490960.aspx
typeperf has two drawbacks:
typeperfwith arguments as english names won't work on non-english machines, andtypeperfwith arguments as numbers will break because those numbers vary by machine. (Source: https://stackoverflow.com/a/39650695)
To avoid those drawbacks, you can use powershell's Get-WmiObject cmdlet. It uses different names compared to typeperf, but you can get the same information, as far as I can tell.
I think that running these commands in powershell will give you what you want:
echo 'Map of process ID to command line:'
Get-WmiObject -Query "Select * from Win32_Process" | Select-Object -Property ProcessId,ExecutablePath,CommandLine | ConvertTo-Csv -NoTypeInformation
echo 'Map of process ID to memory usage:'
Get-WmiObject -Query "Select * from Win32_PerfFormattedData_PerfProc_Process" | Select-Object -Property IDProcess,Name,PageFileBytes,PoolNonpagedBytes,PoolPagedBytes,PrivateBytes,VirtualBytes,WorkingSet | ConvertTo-Csv -NoTypeInformation
echo 'Map of process ID to CPU usage:'
Get-WmiObject -Query "Select * from Win32_PerfFormattedData_PerfProc_Process" | Select-Object -Property IDProcess,Name,PercentProcessorTime | ConvertTo-Csv -NoTypeInformation
echo 'Many people want to do some massaging of the "PercentProcessorTime" numbers above,'
echo 'because in their raw form those numbers (for a single process) can be over 100 percent.'
echo 'So divide all of the "PercentProcessorTime" numbers by this number:'
Get-WmiObject -Query "Select * from Win32_ComputerSystem" | Select-Object -Property NumberOfLogicalProcessors | ConvertTo-Csv -NoTypeInformation
Command-line tool for Windows that reports CPU and Memory utilization per process?
High CPU Usage in Windows Command Processor
High CPU Usage in Windows Command Processor
Get a list of processes and their CPU usage %
Use get-counter, you need to catch values at start and end and do calculations on cooked value. Powershell isn't at fault, it is simply reading the OS counter values. On phone, can't type sample. Search for examples online and adapt something to your needs.
More on reddit.comVideos
Personally I would use Python and the lovely psutil library which can gather just about all of the information that you can dream of:
For a process on Windows you can get:
- cpu_percent
- cpu_times
- io_counters
- memory_info
- memory_maps
- num_ctx_switches
- num_handles
- num_threads
- username
- full exe path
- cmdline
- parent
- status
- cwd
- io_counters
- much more
- even more on Linux & OSX
Some Python 3.5+ code to do more or less what you are asking for to the console, (the same can be done with earlier Pythons but not with the f-string):
import psutil
import time
import datetime
while True:
print(datetime.datetime.now())
for proc in psutil.process_iter():
try:
pr = proc.as_dict()
print(f'{pr["name"]}\t{pr["memory_percent"]}\t{pr["cpu_percent"]}\t{pr["num_threads"]}\t{" ".join(pr["cmdline"][1:]) if pr["cmdline"] else ""}')
except (OSError, psutil.AccessDenied):
print(pr.name(), 'ACCESS DENIED')
print('\n*** Ctrl-C to Exit ***\n\n')
time.sleep(600) # Sleep for 10 Mins
On my machine the output looks like:

You could simply pipe the output to a file or you could modify the code to output to a .csv file directly.
- Free, Gratis & Open Source
- Cross Platform
- Flexible
You could do this simply with a batch file, here's something I quickly wrote up,
@echo off
ECHO ***Date and Time***
set datetimef=%date:~-4%_%date:~3,2%_%date:~0,2%__%time:~0,2%_%time:~3,2%_%time:~6,2%
echo %datetimef%
ECHO ***List Processes***
WMIC path win32_process get Caption,Processid,Commandline
ECHO ***CPU-Usage***
wmic cpu get loadpercentage
ECHO ***Memory Usage***
systeminfo | findstr Memory
It's pretty simple, you can tweak it to fit your needs but this meets your requirements. I also see that you want this data exported to a file so you can, output the contents of the batch file like this, batch.bat > Logs-%date:~10,4%%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%.log
First of all, I knew about WMI - Windows Management Instrumentation - but I must admit I did NOT know about WMIC - WMI Command-Line :)
I have found the following blog post that I think helps here:
Rich's Blog - Get Process CPU Usage Using WMI
http://www.techish.net/2009/03/get-process-cpu-usage-using-wmi/
In that blog post, the author uses the Win32_PerfFormattedData_PerfProc_Process class to get the CPU usage of a process (in several ways).
For instance, if the name of the running process is "iexplore" (Internet Explorer) then you would run:
wmic path win32_perfformatteddata_perfproc_process where (Name=iexplore) get Name, Caption, PercentProcessorTime, IDProcess /format:list
Maybe you can do the following: have one open "Command Prompt" window where you run the "ftp command" and have another "Command Prompt" window where you run the wmic path win32_perfformatteddata_perfproc_processquery.
I hope this helps.
Try this...
wmic path win32_perfformatteddata_perfproc_process where Name="notepad" get Name, Caption, PercentProcessorTime, IDProcess /format:list
I've tried a few different powershell scripts as well as a utility called NTop (HTop for Windows). None of them shows the same values as Windows Task Manager. I've tried on Win 10 and 11.
Does anyone know of a command line tool, preferably portable (single exe), that can report resource utilization per process accurately? Including child-processes, etc.
The use case is using our RMM command line tool to view Task Manager data without interrupting the user.