52

I want to change Windows process priority via command line.

How can I do that?

67
+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")
9
  • 7
    You can also do wildcards wmic process where "CommandLine like '%calc%'" CALL setpriority "below normal" 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?
    – gamer0
    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
  • 2
    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
13

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

2
  • 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
6

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
4
  • 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/… Feb 15 '14 at 16:41
  • No problem. Just that I linked to something pretty similar.
    – harrymc
    Feb 15 '14 at 17:33
5

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.

1
  • 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
    Apr 26 '19 at 0:04
3

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.

0

https://sites.google.com/site/prioclick

Fixed priorities and automatic controls.

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 29 at 17:15
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Toto
    Oct 29 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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