/
/

How to Create a Shortcut to Start a Program with Specific CPU Affinity Settings in Windows 11

How to Create a Shortcut to Start a Program with Specific CPU Affinity Settings in Windows 11 blog banner image

The CPU affinity mask determines which CPU cores are used for specific programs. Normally, your system manages this automatically without any input from the user. However, if you want to fine-tune your experience and ensure that your programs have the appropriate system allocation they need to operate.

Learning how to set a program affinity in a shortcut will help you manage your CPU usage. This will help you optimize your experience, especially if you’re running multi-instance applications and high-load programs like those used for gaming, rendering, and simulation apps. It’s also a good tool for performance tuning and troubleshooting. If you’re running a high-core system, this will be useful in establishing benchmarks for your processes.

A guide on starting a program with a specific CPU affinity setting

You can create a shortcut to a program that will automatically launch with a specific CPU affinity setting using the command line. You can also utilize Windows PowerShell to launch these applications using a scripted deployment.

📌 Recommended deployment strategies:

Click to Choose a Method

💻

Best for Individual Users

💻💻💻

Best for Enterprises

Method 1: Create a shortcut with affinity via the command line
Method 2: Set affinity using PowerShell (one-time or scripted launch)

Things to consider before getting started

  • This guide will require Windows 11 Pro, Enterprise, or Education. These versions are also recommended for multi-core CPUs.
  • You have to know your desired bitmask. To find that, use this tool.
  • You won’t need administrator privileges for this guide unless you also plan to run the program with administrator privileges.

Method 1: Create a shortcut with affinity via the command line

This will create a shortcut on your Desktop. If you want to launch that program with that specific CPU affinity setting, you’ll have to launch it through that shortcut.

  1. Right-click on the Desktop > New > Shortcut.
  2. In the location, type the following and click Next:cmd.exe /c start /affinity 0xFFFFFFFF “” “[C:\Path\To\YourApp.exe]”
    • Replace [C:\Path\To\YourApp.exe] with the path to the app you want to have specific CPU affinity settings.
    • 0xFFFFFFFF is the bitmask for all 32 cores. You can use a CPU affinity mask calculator to identify the hexadecimal code you need.
    • “” is a placeholder for the window title. It’s required syntax. You can leave this blank.
  1. Type a name for the shortcut, and click Finish.
  2. The shortcut will appear on the Desktop now with a cmd icon.
    1. If you want to change the icon, right-click on the shortcut > Properties.
    2. Under the shortcut tab, select Change Icon.
    3. Set it to your preferred icon.
    4. Click OK.
    5. Select Apply > OK.

Method 2: Set affinity using PowerShell (one-time or scripted launch)

This is ideal for scripted deployments in enterprise settings. You can do it using a remote PowerShell tool. However, keep in mind that Windows will not save these settings. You’ll have to deploy this script to your managed devices using your preferred endpoint management tool at the start of each session.

  1. Open the Start Menu and search for Windows PowerShell to open the program.
  2. Type this script and press Enter:

Start-Process "[C:\Path\To\YourApp.exe]" -ArgumentList "" -WorkingDirectory "C:\Path\To" -NoNewWindow

Start-Sleep -Seconds 1

(Get-Process YourAppName).ProcessorAffinity = 0xFFFFFFFF

    • Replace [C:\Path\To\YourApp.exe] with the path to the program of your choosing.
    • 0xFFFFFFFF is the bitmask for all 32 cores. If you want to use specific CPU cores, you can use a CPU affinity mask calculator to identify the hexadecimal code.
  1. This will launch the chosen program and apply the affinity bitmask once it starts.

Additional considerations when changing the CPU affinity setting of a program

  • If a program also requires admin privileges, you can use Windows Task Scheduler to combine elevation with affinity. To do that, follow these steps:
    1. Open the Start Menu and search for Task Scheduler to open the program.
      Type cmd.exe /c start /affinity 0xFFFFFFFF “” “[C:\Path\To\YourApp.exe]” in location and replace [C:\Path\To\YourApp.exe] with your chosen program.
    2. Check the box that says Run with highest privileges, and modify the settings according to your needs.
  • If your system has more than 64 logical processors, affinity management will involve processor groups. This guide will not apply to that situation.
  • You’ll have to launch your selected program from the shortcut you created to ensure that the affinity bitmask will always apply.
  • If you use Method 2, it will only apply once the program is launched. Windows will not remember the affinity setting, and it will have to be applied for each session.

What is a core affinity mask, and how do you find it in your computer

A computer CPU has multiple cores to run all your processes and programs. Normally, the system manages which cores will run on its own, depending on your needs and the capability of your cores.

But, if you want to have greater control over which core will run a specific program, you’ll need a core affinity mask. That will bind that specific application to your designated core, and can be done using command line or Windows PowerShell.

Why should I set CPU affinity?

Setting the CPU affinity for specific programs is useful for performance tuning for different tasks such as gaming, rendering, and running simulation apps. This allows you to fine tune and optimize your CPU usage.

This also helps you prevent conflicts on specific cores and manage multi-instance applications. If you’re working on high-core-count systems, managing your CPU affinity will also help you establish benchmarks and test the capabilities of your system.

⚠️ Things to look out for

Risks Potential Consequences Reversals
Changing the CPU affinity can lead to inefficient core usage and impact performance. It can lead to system instability. You may experience reduced performance and system crashes. Close the application where you applied the different CPU affinity. If the problem persists, restart your computer.

Optimize your CPU usage by changing a program’s CPU affinity settings

Setting the CPU affinity allows you to control how programs utilize system resources. Some applications will require more, and some will require less. To fine-tune your performance, you can assign specific cores for each program to further optimize your experience.

You can use the command line while creating a shortcut to have a convenient way to launch a program with a specific CPU affinity setting. For enterprise settings, you can also take advantage of Windows PowerShell for scripted deployments. However, please keep in mind that Windows will not remember these affinity settings, and they have to be reset every time you launch that application.

Related Links:

You might also like

Ready to simplify the hardest parts of IT?
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).