34

I want to change Windows process priority via command line.

How can I do that?

48
+100

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:

  • idle: 64 (or "idle")
  • below normal: 16384 (or "below normal")
  • normal: 32 (or "normal")
  • above normal: 32768 (or "above normal")
  • high priority: 128 (or "high priority")
  • real time: 256 (or "realtime")
  • 7
    You can also do wildcards wmic process where "CommandLine like '%calc%'" CALL setpriority "below normal" – laggingreflex Feb 16 '14 at 17:59
  • Its possible to do the same for Background(low IO and memory priority) like in Process Explorer? – miky Aug 5 '14 at 8:53
  • will this work even on "cmd.exe" from batch? ...batch that will start that cmd.exe? – user902300 May 23 '18 at 16:35
  • 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 Aug 7 '18 at 3:07
  • why is below/above normal value is so large and strange? And why is normal less than both idle and realtime? – phuclv Sep 5 '18 at 4:54
9

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 Aug 7 '18 at 3:08
  • 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 Dec 3 '18 at 15:01
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 Feb 12 '14 at 15:15
  • @harrymc It answers the original question, using PowerShell. – paradroid Feb 12 '14 at 17:00
  • @harrymc - actually I am repeating what I said from DEC. stackoverflow.com/questions/20693028/… – Knuckle-Dragger Feb 15 '14 at 16:41
  • No problem. Just that I linked to something pretty similar. – harrymc Feb 15 '14 at 17:33
4

In addition to existing answers, the question Windows Equivalent of 'nice' lists some more solutions:

  1. Using the command START in the command-prompt (CMD).
  2. Using the free ProcessTamer to set up a rule on the .exe that is automatically enforced whenever that process is started.
  3. Using a PowerShell script contained here.
  4. Using a VBScript script contained here.

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.

0

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.