42
20
I want to change Windows process priority via command line.
How can I do that?
42
20
I want to change Windows process priority via command line.
How can I do that?
55
The 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:
11
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
The first set of quotes is mandatory, even if not using multiple words. It must also be passed to the command, rather than being interpreted by the shell. – piojo – 2018-08-07T03:08:45.843
On win10 Pro 1809, "low" is not a recognized value - it throws an error. using "Idle" causes the process to be displayed as "low" priority in task manager... – ljwobker – 2018-12-03T15:01:21.650
5
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.
The obvious snag with the vbScript solution is that it takes 23 lines of code to accomplish its task (i.e. set the priority level), where the START command takes only 2 lines to do so (one, at a pinch, hence it even works at a bare command prompt): start "" /realtime /b /w program.exe – Ed999 – 2019-04-26T00:04:58.017
5
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
What's the point of repeating what was already said before? – harrymc – 2014-02-12T15:15:46.353
@harrymc It answers the original question, using PowerShell. – paradroid – 2014-02-12T17:00:10.877
@harrymc - actually I am repeating what I said from DEC. http://stackoverflow.com/questions/20693028/powershell-script-that-runs-in-background-changing-specific-process-priority-to/20694903#20694903
– Knuckle-Dragger – 2014-02-15T16:41:57.507No problem. Just that I linked to something pretty similar. – harrymc – 2014-02-15T17:33:25.210
1
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.
Its possible to do the same for Background(low IO and memory priority) like in Process Explorer? – miky – 2014-08-05T08:53:32.737
will this work even on "cmd.exe" from batch? ...batch that will start that cmd.exe? – gamer0 – 2018-05-23T16:35:54.210
Note: the first set of quotes is mandatory, so in other shells the quotes must be escaped (or double-quoted). In Cygwin:
wmic process where 'name="calc.exe"' CALL setpriority "idle"
– piojo – 2018-08-07T03:07:39.2402why is below/above normal value is so large and strange? And why is normal less than both idle and realtime? – phuclv – 2018-09-05T04:54:20.603
Doesn't work on windows 8 – None – 2018-09-27T01:52:06.927
Works fine on Window$ 10.0.17134.648 Enterprise x64. – rautamiekka – 2019-04-17T13:09:51.383
7You can also do wildcards
wmic process where "CommandLine like '%calc%'" CALL setpriority "below normal"
– laggingreflex – 2014-02-16T17:59:56.280