Processor affinity lets you tell Windows which CPU cores a program is allowed to use. This can help older games run better, reduce interference from background tasks, or stop a misbehaving process from hogging all cores. You can set it for a single session using Task Manager, or make it permanent with a small script. No special software is needed—everything is built into Windows.
What You’ll Need
- A Windows PC (Windows 10 or 11 works for the Task Manager method)
- Administrator rights if you want to change affinity for a system process or make it permanent
- Optional: a text editor like Notepad to create a script for a permanent setting
Step-by-Step
- Open Task Manager by pressing Ctrl + Shift + Esc (or right-click the taskbar and choose “Task Manager”).
- If Task Manager opens in compact view, click “More details” at the bottom.
- Go to the Details tab. This lists every running process with its process ID (PID).
- Find the process you want to control. If you’re not sure which one it is, right-click it and select “Open file location” to verify the path.
- Right-click the process name and choose Set affinity.
- A dialog appears showing all CPU cores (e.g., CPU 0, CPU 1, CPU 2…). Check the boxes for the cores you want the process to use, then click OK.
- That’s it for a temporary change. The setting lasts until the process ends or you reboot.
To make the affinity permanent (so it applies every time the program starts), you can use a PowerShell script. Here’s how:
- Open Notepad and paste this script, replacing
YourApp.exewith the actual executable name and0x3with the core mask you want (see Tips below for how to calculate it):
Start-Process -FilePath "C:\Path\To\YourApp.exe" -PassThru | ForEach-Object { $_.ProcessorAffinity = 0x3 }
- Save the file with a
.ps1extension (e.g.,setaffinity.ps1). - Right-click the file and choose “Run with PowerShell” every time you start the program. For a fully automatic launch, place a shortcut to the script in your startup folder (press Win + R, type
shell:startup, and press Enter).
Common Mistakes
- Choosing the wrong process: Many programs spawn multiple child processes. For example, Chrome has many processes; you need to set affinity on the one that actually does the heavy work (often the one using the most CPU).
- Deselecting all cores: Windows won’t allow you to uncheck every CPU. If you try, you’ll get an error. Always leave at least one core selected.
- Expecting the setting to stick: Task Manager affinity is temporary. If you close the program or restart your PC, the setting is lost. Only a script or third-party tool can make it permanent.
- Forgetting that some games reset affinity: Some anti-cheat systems or game launchers may override your setting. If the change doesn’t stick, check if the game has its own CPU settings.
Tips
- Understand core numbers: In the affinity dialog, “CPU 0” is the first logical processor. On a system with hyper-threading, you may see twice as many CPUs as physical cores. Windows treats each logical processor as a separate “CPU”.
- Use hex masks for scripts: The PowerShell script uses a bitmask. For example, to use only core 0, the mask is
0x1; cores 0 and 1 is0x3; cores 0, 1, 2, and 3 is0xF. Each core corresponds to a bit: core 0 = bit 0 (value 1), core 1 = bit 1 (value 2), core 2 = bit 2 (value 4), core 3 = bit 3 (value 8). Add the values for the cores you want. - Test with a CPU-heavy task: To see if affinity helps, run a benchmark or a demanding game before and after. Use Task Manager’s Performance tab to watch core usage.
- Don’t over-restrict: Giving a process only one core on a modern CPU can slow it down. Usually, you want to exclude certain cores (e.g., leave core 0 for system tasks) rather than limit to one.
Troubleshooting
“Set affinity” is grayed out. This usually means you don’t have permission. Run Task Manager as administrator (right-click the Task Manager shortcut and choose “Run as administrator”).
The process doesn’t appear in the Details tab. Make sure you’re looking at the right tab. Some background processes may be under “Background processes” in the Processes tab, but they still show in Details. If you can’t find it, use the Search box in Task Manager.
The setting resets immediately. Some programs (especially games with anti-cheat) enforce their own affinity. Check if the program has a config file or launch option to set CPU affinity. If not, you may need to use a third-party tool like Process Lasso (not covered here).
PowerShell script doesn’t work. Make sure you’ve replaced the path and executable name correctly. Also, PowerShell may be blocked by execution policy. Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned in an admin PowerShell to allow local scripts.
You can’t select any cores. Windows requires at least one core. If all are grayed out, your system may have only one core (unlikely) or a system policy is restricting it. Check if the process is a protected system process.
Frequently Asked Questions
Q: Does changing affinity improve performance?
A: Sometimes. It can help if a program is fighting with background tasks for the same core, or if you want to dedicate a core to a specific app. But on modern multi-core CPUs, Windows’ scheduler is usually good enough, so gains are often minimal.
Q: Can I set affinity for all processes at once?
A: No, Windows doesn’t have a built-in way to set a default affinity for every process. You’d need a third-party tool or a system-wide script.
Q: Is processor affinity the same as CPU priority?
A: No. Affinity controls which cores a process can use; priority controls how much CPU time it gets relative to other processes. You can set both independently.
Q: Does affinity affect all threads of a process?
A: Yes, the affinity you set applies to every thread of that process. You can’t set per-thread affinity with Task Manager.
Q: Will setting affinity damage my CPU?
A: No. It only changes which cores a process uses. It doesn’t change voltage, clock speed, or anything that could cause damage.
Q: Can I set affinity for a UWP app (from Microsoft Store)?
A: Yes, as long as the process appears in the Details tab. Some UWP apps have multiple processes, so you may need to identify the right one.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Gmail Gemini Privacy: Data Access & Limit Settings
- Fix Outlook Inbox Corruption with DISM in Windows
- How to Set Up Apple Pay on iPhone
- How to Choose a Refurbished iPhone With Years of Support
- Voice Dictation in Google Docs: How to Use It
- Turn Off Message Notifications on Mac