Now if you find that running an application on a specific CPU core works well, you might want to use it again in the future. If so, chances are that you won’t want to have to go through the Task Manager each time. Fortunately you can create a shortcut to launch an application with a specific affinity setting.
For example, to launch Disk Defragmenter so that it runs only on CPU 0, you would create a shortcut with the following command line:
C:\Windows\System32\cmd.exe /C start /affinity 1 dfrgui.exe
To launch Disk Defragmenter on CPU 1, you would create a shortcut with the following command line:
C:\Windows\System32\cmd.exe /C start /affinity 2 dfrgui.exe
The number that follows the
start /affinity command is called the affinity mask and is defined as a hexadecimal number. However, the CPU core number can be calculated more easily using binary numbers. For instance, the command
C:\Windows\System32\cmd.exe /C start /affinity 3 dfrgui.exe
will launch Disk Defragmenter on both CPU 0 and CPU 1. If you convert 3 into a binary number you will get 0011. Under the affinity mask system, processors are numbered from the right to left beginning with 0 and since there are 1’s in the first two places, this indicates CPU 0 and CPU 1.
Suppose you have a Quad core processor. If so and you use an affinity mask of 4, that will convert into binary 0100, which indicates CPU 2. If you use an affinity mask of 9, that will convert into binary 1001, which indicates CPU 0 and CPU 3.
For more information on the
start /affinity command, open a Command Prompt window and type the command