I want to change Windows process priority via command line.
How can I do that?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityThe command line syntax:
wmic process where name="AppName" CALL setpriority ProcessIDLevel
Example:
wmic process where name="calc.exe" CALL setpriority 32768
or
wmic process where name="calc.exe" CALL setpriority "above normal"
Priority:
wmic process where "CommandLine like '%calc%'" CALL setpriority "below normal"
Feb 16, 2014 at 17:59
wmic process where 'name="calc.exe"' CALL setpriority "idle"
A small addition.
You can also use string values instead of integers (easier to memorize) like that:
wmic process where name="calc.exe" CALL setpriority "idle"
Possible values: "idle", "low", "below normal", "normal", "above normal", "high priority", "realtime"
PS. Don't forget the quotes, especially if using multiple words in a string value
From batch command line I would simply use PowerShell. This example starts calc.exe, finds its process and adjusts its priority class to "IDLE", aka LOW:
start /b /wait powershell.exe -command "calc.exe;$prog = Get-Process -Name calc;$prog.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::IDLE"
Specify one of the following enumeration values: "Normal, Idle, High, RealTime, BelowNormal, AboveNormal
"
Here is the same thing from PowerShell with split lines:
calc.exe
$prog = Get-Process -Name calc
$prog.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::IDLE
In addition to existing answers, the question Windows Equivalent of 'nice' lists some more solutions:
Additionally, the old SetPriority utility might still work, but I haven't tried it for many years now.
Some of these solutions may not work on system services or may need to be Run as Administrator.
I am running Windows 7 64-bit.
The wmic command is not reliable. In my considerable experience, it fails unexpectedly for too many (mostly inexplicable) reasons.
The best possible command, because of its reliability, is the START command. The syntax is very simple (this is the 3-line run command for a batch file):
:: Boost thread priority
SET command=<program.exe> <options>
start "" /REALTIME /B /W %command%
In my opinion its high degree of reliability stems from the fact that it sets the priority level with which the .exe program is launched, rather than trying to meddle with priority after the program has begun running with a different priority.
https://sites.google.com/site/prioclick
Fixed priorities and automatic controls.