CPU Affinity Shortcut for a Program - Create in Windows

How to Create a Shortcut to Run an Application with a Set CPU Affinity in Windows


Processor affinity or CPU Pinning enables the binding and un-binding of a process or thread to a physical CPU or a range of CPUs, so that the process or thread in question will run only on the CPU or range of CPUs in question, rather than being able to run on any CPU

By default, Windows runs an application on all available cores of the processor. If you have a multi-core processor, then this tutorial will show you how to set the processor affinity of an application to control which core(s) of the processor the application will run on.

If the application and CPU supports Symmetric Multiprocessing (SMP) or HyperThreading (HT), then Windows will automatically adjust the application's usage of each processor core for the best performance. You will not gain much, if anything, from manually changing the processor affinity for these type of applications.

If you have more then one processor intensive applications running, then you could improve their performance by setting the processor affinity of their processes to run on a different core(s). This way they are not competing for the resources of the same core(s).


This tutorial will show you how to create a shortcut that will always run an application with a set CPU affinity by default in XP, Vista, Windows 7, and Windows 8.



Here's How:

1. This step will show you how many CPU cores you have, and how to figure the hex value to use at step 3 below for the CPU(s) you want to run the application on.

NOTE: If you should need any assistance with this step, then please feel free to post. I'll be happy to help.


A) Open Task Manager (CTRL+Shift+ESC) in more details view, click/tap on the Processes (XP, Vista, Windows 7) OR Details (Windows 8) tab, right click or press and hold on any process in the Name column, and click/tap on Set affinity. (see screenshot below)

NOTE: This will show you how many CPU cores you have. I have 12 CPU cores numbered from 0 to 11.

Task_Manager_Affinity-all.png


B) For how many CPU cores you have will also be how long the binary number will be. Since I have 12 CPU cores, the binary number will be 12 zeros 000000000000. Each zero in the binary number represents a CPU core number from right to left. In my case with 12 CPU cores, the far right 0 in the binary number will be for CPU 0, and the far left 0 will be for CPU 11. (see screenshot below)

C) For each CPU number you want to run the application on, replace 0 (off) with 1 (on) in the binary number for the CPU numbers.

For example, if I wanted to run the application only on CPU 0, then my binary number would be changed to 000000000001. To run the application on CPU 0 and CPU 3, I would use 000000001001. (see screenshot below)

binary.jpg


D) Go the website below, and type your binary number from step 1C above into the Binary field. This will convert the binary number to a hexadecimal (hex) that you will need to use at step 3 below.

Website: Binary/Decimal/Hexadecimal Converter


For example, with my 000000000001 binary number, I get a hex value of 1. (see screenshot below)

Binary-Decimal-Hexadecimal-Converter.png


2. Right click or press and hold on an empty area of your desktop, and click/tap on New and Shortcut.

3. Type the command below into the location area, and click/tap on the Next button. (see screenshot below)


cmd.exe /c start "Program Name" /affinity # "Full path of application file"


For example: I would type this command below exactly if I wanted to create a shortcut to run Process Monitor on only CPU 0 (step 1), and it's .exe file is located at "E:\Programs\Process Monitor 3.05\Procmon.exe".

(For only on CPU 0)
cmd.exe /c start "Process Monitor" /affinity 1 "E:\Programs\Process Monitor 3.05\Procmon.exe"

(For on CPU 0 and CPU 3)
cmd.exe /c start "Process Monitor" /affinity 9 "E:\Programs\Process Monitor 3.05\Procmon.exe"


Note   Note
Substitute Program Name in the command with the actual program's name within quotes.

Substitute # in the command for the affinity # with the hex value (ex: 1) from step 1D above.

Substitute Full path of application file in the command with the full path of the file within quotes.




shortcut-1.jpg

4. Type any name you would like to give the shortcut, and click/tap on the Finish button. (see screenshot below)

shortcut-2.jpg

5. Right click or press and hold on the new shortcut, and click/tap on Properties.

6. Click/tap on the Shortcut tab, then click/tap on the Change Icon button. (see screenshot below)

Shortcut-3.png

7. In the line under "Look for icons in this file", copy and paste the same full path of the application file used in the shortcut below, and press Enter. (see screenshot below)

For example: E:\Programs\Process Monitor 3.05\Procmon.exe


Shortcut-4.jpg

8. Select (highlight) the icon you want for the shortcut, and click/tap on OK. (see screenshot above)
NOTE: You can use any icon that you would like instead though.

9. Click/tap on OK. (see screenshot below step 6)

10. In Vista and Windows 7, you can now Pin to Taskbar (Windows 7 only) or Pin to Start Menu, add to Quick Launch, assign a keyboard shortcut to it, or move this shortcut to where you like for easy use.

11. In Windows 8, you can Pin to Taskbar on desktop, Pin to Start screen, add to Quick Launch, assign a keyboard shortcut to it, or move this shortcut to where you like for easy use.



That's it,
Shawn


 

Attachments

  • CPU.jpg
    CPU.jpg
    2.9 KB · Views: 568
Last edited by a moderator:
This is a very helpful and in detail guideline on having permanent CPU affinity set with some program. However, my recent experiences makes me to realize that setting affinity is not actually that much practically safer strategy for a CPU hog application, it still risks blowing out one or more CPU cores. The closest and safest alternate is to limit maximum processor state in power configuration. I run media transcoding operations on a regular basis and my system is a Plex Media Server too, thus the system often undergoes media transcoding processes and it is a real pain to keep an eye on the system when I am not at home. Also, the affinity solution is not really that much practical for service controlled programs.

The best I came up with is to set the power configuration to "High performance" with a setting of maximum processor state to 80% on main power line (it goes fine with 85% but I just reserved the 5% for other simple operations to keep within the margin). This way, the CPU hungry processes still run at their optimum performance without having me to worry about CPU over heat/load. This also sets me free from actually figuring out which applications should be throttled and which not.

The peace of mind is that my CPU no more makes panic whistles and am sleeping like a trunk :)
 

My Computer

System One

  • OS
    Microsoft Windows 7 Ultimate x64
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom
    CPU
    Intel Core i7 920
    Motherboard
    Gigabyte GA-EX58-UD3R
    Memory
    16 GB DDR III @ 1066 MHz
    Graphics Card(s)
    nVidia GeForce GT 640
    Browser
    Microsoft Internet Explorer 11 x64
    Antivirus
    Microsoft Security Essentials
Hello SkJoy, and welcome to Eight Forums.

I agree. Windows usually does a great job of managing your system resources. I find this is useful if you wanted to use it on a program to either give it more or less CPU resources if it doesn't perform how you want it normally. :)
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
Hello SkJoy, and welcome to Eight Forums.

I agree. Windows usually does a great job of managing your system resources. I find this is useful if you wanted to use it on a program to either give it more or less CPU resources if it doesn't perform how you want it normally. :)
Yeah this is especially helpful with specific applications where slowing down is a necessity, like arcade game emulators.
 

My Computer

System One

  • OS
    Microsoft Windows 7 Ultimate x64
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom
    CPU
    Intel Core i7 920
    Motherboard
    Gigabyte GA-EX58-UD3R
    Memory
    16 GB DDR III @ 1066 MHz
    Graphics Card(s)
    nVidia GeForce GT 640
    Browser
    Microsoft Internet Explorer 11 x64
    Antivirus
    Microsoft Security Essentials
it'd be nice to see the final version of the sohrt cut with a screen shot, where everything is entered is it in the target field, or in the start in field, and what they look like..
 

My Computer

System One

  • OS
    windows 8.1 and server 2012 R2
Hello m18xr2, :)

The examples under step 3 is what would be in the target field.
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
Thanks so much! I was just thinking about how to set this up for Minecraft, since it can only use one core anyways, and this solution is so simple and works perfectly!
 

My Computer

System One

  • OS
    Windows 8.1
    Computer type
    PC/Desktop
    System Manufacturer/Model
    CyberPowerPC
    CPU
    AMD FX 4300 Quad Core
    Graphics Card(s)
    MSI NVidia GTX 970
You're most welcome thaecrasis. I'm glad it could help. :)
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
Does anyone know how to do this for windows 10 pro? This doesnt seem to work for me. Below is my shortcut. I have an 8 core CPU (4790K) and id like cores 4,5,6,7 to be used.


C:\Windows\System32\cmd.exe /c start "FarCry4.exe" /affinity F "C:\Games\Far Cry 4\bin\FarCry4.exe" -skipintro 1
 

My Computer

System One

  • OS
    Windows 10
Hello IOKBB, and welcome to Eight Forums. :)

Games can be a bit more tricky since the .exe often loads other processes for it.

How does the command below run without the -skipintro 1 switch on it?

cmd.exe /c start "FarCry4.exe" /affinity F "C:\Games\Far Cry 4\bin\FarCry4.exe"
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
Hello IOKBB, and welcome to Eight Forums. :)

Games can be a bit more tricky since the .exe often loads other processes for it.

How does the command below run without the -skipintro 1 switch on it?

cmd.exe /c start "FarCry4.exe" /affinity F "C:\Games\Far Cry 4\bin\FarCry4.exe"


Still doesnt work. I can get it to work in notepad but not this app
 

My Computer

System One

  • OS
    Windows 10
As a test, are you able to manually set CPU affinity for it?
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
I double checked your command, and it should be this below instead for an 8 core CPU. Hopefully that'll do the trick for you. :)

cmd.exe /c start "FarCry4.exe" /affinity F0 "C:\Games\Far Cry 4\bin\FarCry4.exe"
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
I double checked your command, and it should be this below instead for an 8 core CPU. Hopefully that'll do the trick for you. :)

cmd.exe /c start "FarCry4.exe" /affinity F0 "C:\Games\Far Cry 4\bin\FarCry4.exe"

Still doesnt work, oh well thanks for the help. Ill have to set it the old fashion way from now on :)
 

My Computer

System One

  • OS
    Windows 10
Sorry about that. :(
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
I have tried this but it tells me that windows cannot find "SONARPLT.exe". Make sure you type the name correctly, and then try again. I have tried using the name as "SONAR PLATINUM" but the same occurs. And yes, I input it without the quotes.
 

My Computer

System One

  • OS
    Windows 10 64bit
    Computer type
    PC/Desktop
    System Manufacturer/Model
    HP
Hello mariachipr, and welcome to Eight Forums. :)

Please go ahead and post the command you used for the shortcut's location to see if anything may be wrong with it.
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
cmd.exe /c start SONAR Platinum /affinity E C:\Program Files\Cakewalk\SONAR Platinum\sonarplt.exe
 
Last edited:

My Computer

System One

  • OS
    Windows 10 64bit
    Computer type
    PC/Desktop
    System Manufacturer/Model
    HP
also tried cmd.exe /c start SONARPLT.exe /affinity E C:\Program Files\Cakewalk\SONAR Platinum\sonarplt.exe
 

My Computer

System One

  • OS
    Windows 10 64bit
    Computer type
    PC/Desktop
    System Manufacturer/Model
    HP
Back
Top