Starting a Program With a Preset Affinity

Setting manual affinities for CPUs so you can manually optimize the way your games/tasks are handled is a quick way to gain some free performance that is left out by the Windows Scheduler. You have utilities like Process Hacker/Lasso that allow you to do this but then you need to have these apps open and never close your target application. 

If you close Process Hacker/Lasso and you open your app again it will no longer use the affinity invalidating your effort. There is however a quick way around this situation that allows you to launch your .exe files with a preset affinity.

Creating a .Bat File

To launch any application on your computer (that is not protected by anti-cheat software) with a preset affinity you need to follow a couple of steps:

  1. Create a notepad file and write in the base command: start /affinity
  2. Go to this site and then figure out the bit mask for the cores you want to use
affinity mask calculator
  1. Add the mask for the cores and the path to the .exe file you want to launch with those cores as affinities
start affinity

In my case, this bat file will open foobar2000 with an affinity for the 3rd and 4th cores on my CPU.

  1. To check that the affinity has been applied you can just open the task manager and see what cores the .exe is running on
affinity gif

You can use the same process for any program that you want to schedule for specific cores to either increase their performance or decrease their importance. There are however games/applications that are protected by anti-cheat software that will not allow you to set the affinity in any way.

If the process you want to manage the affinity for starts on boot it is simpler to use the aforementioned Process Hacker or Lasso and close them afterwards. 

Things to Note

Although the Windows Scheduler can be helped sometimes with our manual efforts, in a lot of cases you might be losing performance by manually setting affinities for certain games and apps if you do not understand what kind of usual behavior they display. 

A simple example would be setting an application that heavily benefits from multithreaded work to a single core and gimping its performance. The most useful aspect of manual affinity tuning is when you have many cores (8+ physical cores) or have an Intel CPU with P+E cores so you want to separate the loads accordingly – games on P cores, background apps on E cores. 

I suggest you run benchmarks and test your FPS performance in games since you could be running worse than default when manually fiddling with affinities. 

About The Author

Chris (vile_is_dead)

Custom Windows ISO enjoyer, FPS optimizer, and aim improvement enthusiast. Will disassemble all of his peripherals (and sometimes PC parts) to mod them even if all of them work perfectly fine. Discord/Twitter: vile_is_dead

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments