Changes the priority level of the first matching process.

ProcessSetPriority Level , PIDOrName



Type: String

Specify one of the following words or letters:

Note that any process not designed to run at Realtime priority might reduce system stability if set to that level.


Type: Integer or String

If blank or omitted, the script's own process is used. Otherwise, specify either a number (the PID) or a process name:

PID: The Process ID, which is a number that uniquely identifies one specific process (this number is valid only during the lifetime of that process). The PID of a newly launched process can be determined via the Run function. Similarly, the PID of a window can be determined with WinGetPID. ProcessExist can also be used to discover a PID.

Name: The name of a process is usually the same as its executable (without path), e.g. notepad.exe or winword.exe. Since a name might match multiple running processes, only the first process will be operated upon. The name is not case sensitive.

Return Value

Type: Integer

This function returns the Process ID (PID) of the specified process. If a matching process is not found or cannot be manipulated, zero is returned.


The current priority level of a process can be seen in the Windows Task Manager.


Run, Process functions, Win functions


#1: Launches Notepad, sets its priority to "High" and shows its current PID:

Run "notepad.exe", , , NewPID
ProcessSetPriority "High", NewPID
MsgBox "The newly launched Notepad's PID is " NewPID

#2: A hotkey to change the priority of the active window's process:

#z:: ; Win+Z hotkey
    MyGui := Gui.New(, "Set Priority")
    MyGui.Add("Text",, "
        Press ESCAPE to cancel, or double-click a new
        priority level for the following window:
    MyGui.Add("Text", "wp", WinGetTitle("A"))
    LB := MyGui.Add("ListBox", "r5 vLB Choose1", ["Normal","High","Low","BelowNormal","AboveNormal"])
    SetPriority := Func("SetPriority").bind(WinGetPID("A"))
    LB.OnEvent("DoubleClick", SetPriority)
    MyGui.Add("Button", "default", "OK").OnEvent("Click", SetPriority)
    MyGui.OnEvent("Escape", (*) => MyGui.Destroy())
    MyGui.OnEvent("Close", (*) => MyGui.Destroy())

SetPriority(PID, this, *)
    LB := this.Gui["LB"]
    if ProcessSetPriority(LB.Text, PID)
        MsgBox "Success: Its priority was changed to '" LB.Text "'."
        MsgBox "Error: Its priority could not be changed to '" LB.Text "'."