Welcome to the new world
Software, Apps & OS

How to Auto Set Priority and Affinity in Windows 11/10 with Script

If you’re one of the many people who are keen to automate your computer’s settings, then this is for you. Here we will show how to set priority and affinity in Windows 10 with a simple script.

This is a tutorial on how to set priority and affinity in Windows 10. This tutorial will teach you how to auto set priority and affinity with a script.

When you need to run numerous CPU-intensive programs or games, setting CPU priority and/or affinity is an excellent approach to control the sharing of CPU resources. You may build a shortcut for most applications and programs that operate on just one.exe process so that they always start with a certain priority and CPU affinity. Go to How to Set Process CPU Affinity or Priority Permanently in Windows 11/10 to discover how.

The shortcut technique will not work for other programs that run many executable processes, such as those run by most current browsers like chrome.exe, firefox.exe, or msedge.exe, since it only applies to the first process the app starts. In such instance, a PowerShell script may be used to automatically adjust the priority and affinity for many processes, even if they have the same name.

In Windows 11/10, the CPU priority and affinity are automatically configured.

In this video, you’ll learn how to use PowerShell to adjust the CPU priority and/or processor affinity for programs that run multiple processes, such as Chrome in Windows 11 or Windows 10.

In the example below, I’ll use PowerShell to change the priority of all chrome.exe processes to “Low” and the affinity of all processes with the name “chrome” to “CPU 7” alone. You may use the same techniques and adjust the value to suit your needs.

Create a PowerShell script first.

Make a text file with whatever name you like, but with the extension. ps1. A PS1 file is a script that may include a succession of PowerShell commands that can be launched when the file is opened.


Open the.ps1 file with Notepad or another appropriate text editor after it has been produced.


Step 2: Type the command to set the process priority automatically.

To automatically set the priority for any process with a certain name, add the following command line to the PowerShell script.

Get-WmiObject Win32 process -filter ‘name = “chrome.exe”‘ | foreach-object $_.SetPriority(64) | Get-WmiObject Win32 process -filter ‘name = “chrome.exe”‘

This command will look for any process named “chrome.exe” in the process list and adjust its process priority to “Low” (the value for low priority is 64). Replace chrome.exe with the name of the process you’d want to give priority to, and set the priority value in SetPriority(value) to the value shown in the table below.

Realtime 256
High 128
over average 32768
Normal 32
Below average 16384
Low 64


Skip to step 5 if you don’t want to use this script to change CPU affinity for any processes.

Step 3: Determine the decimal value of the CPU cores (affinity) that will be used in the process.

You must first obtain the decimal number of the CPU core(s) you wish to utilize for a process since the PowerShell command in the following step demands it. This value will be required later in the command.

To get the decimal value, first determine the binary number of the CPU cores you want to employ for a process.

The number of CPU cores determines the length of a binary integer. 0 indicates “off” and 1 means “on” in the CPU binary number. Change 0 to 1 for each CPU core you wish to utilise for the operation.


For example, I have a 12-core CPU in the picture above, and I only want to utilize CPU 10 and CPU 11 for chrome processes. As a result, the CPU I wish to utilize has a binary number of 110000000000.

For example, if your CPU has eight cores and you only want to utilize CPUs 0 and 1 for your program or game, the binary number to use is 00000011.

Because the command line wants the decimal number of CPU cores rather than the binary number, you must use a converter to convert the binary number to decimal. This website includes a binary to decimal converter.


In my case, the decimal number of the CPU cores I wish to employ (CPU 10 and CPU 11) is 3072. Proceed to the following step after you have the decimal value.

Step 4: Run the command to establish CPU affinity automatically.

For a single operation:

Enter the command line below into the PowerShell script if you just want to set the CPU affinity for one process.

$Process = Get-Process Messenger; $Process.ProcessorAffinity=3072; $Process.ProcessorAffinity=3072; $Process.ProcessorAffinity=3072; $Pro

This command will search for the Messenger process and set its processor affinity to 3072, which corresponds to CPU cores 10 and 11. Replace the process name and the CPU affinity value as needed.

If there are numerous processes with the same name, use the following syntax:

Enter the command line below into the PowerShell script to adjust the CPU affinity for all processes with the same name, such as chrome.exe, firefox.exe, or msedge.exe.

$PROCESS.ProcessorAffinity=3072 $PROCESS.ForEach($PROCESS in GET-PROCESS chrome)

The command above will go through all current processes for those that include the word “chrome” and adjust the CPU affinity for each of them to 3072 (CPU 10 and CPU 11).

Replace “chrome” with the name of the process for which you wish to configure CPU affinity, and “affinity” with the decimal number you got in step 3.

Step 5: Put the script into action.

The image below shows how it appears in my PowerShell script. This script will check for all processes named chrome.exe and set their priority to Low (the first command line), as well as any processes containing the word “chrome” and set their CPU affinity to only use CPU 10 and 11 in a 12-core CPU machine (second command line).


Right-click the.ps1 file you updated and choose Launch with PowerShell to run the script.


When you execute the script, it will give you an Execution Policy Change warning. Windows does not allow any scripts to execute on the system by default. Press Y to enable your script to execute. After all of the instructions in the script have been executed, the script will run and shut itself.


Check the processes in Task Manager after you’ve ran the script. You should observe that the processes’ CPU affinity and priority are configured appropriately.

Due to the execution policy, the script cannot be executed.

You may construct a shortcut referring to the ps1 script you prepared earlier with parameters that circumvent the execution policy if you don’t have admin permissions or if the script isn’t executing due to execution policy.

To do so, right-click anywhere on the desktop and choose New > Shortcut from the menu that appears. In the “Type the location of the item” area of the Create Shortcut wizard, type the following line.

-noexit -ExecutionPolicy Bypass -File “C:UsersalvinsecondaryOneDriveDesktopscript.ps1” C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -noexit -ExecutionPolicy Bypass -File “C:UsersalvinsecondaryOneDriveDesktopscript.ps1”

Note: Replace the location to your PS1 script file with “C:UsersalvinsecondaryOneDriveDesktopscript.ps1.” Replace “C:WindowsSystem32WindowsPowerShellv1.0powershell.exe” with the path to the powershell.exe on your machine if Windows is not installed in C: drive or if your powershell is installed elsewhere.


The -noexit option is not required. This argument instructs the shortcut not to shut the window when the script has completed.

After that, you may call the shortcut anything you like. Bypassing Windows’ Execution Policy, this shortcut will be allowed to launch your PS1 script.

Watch This Video-

If you want your computer to automatically set the priority and affinity in Windows, then you can use a script. The “windows 10 set affinity missing” is a command-line tool that will allow you to do this.

Related Tags

  • how to set affinity without task manager
  • set affinity windows 10
  • set affinity command line windows 10
  • set priority windows 10
  • set affinity regedit