1

Is it possible to set program affinity without opening the task manager in Windows 8.1 using the program shortcut? (by using a command like -setaffinity)

Is this method (changing affinity) a good way of limiting a program's CPU usage?

0

You can create a batch file with

start /affinity 1 PATH_TO_EXE.exe

Just call this batch file in your shotcut. This will run it with only CPU 0. Change the affinity mask (this is the hex value) for more cores.

CPU3 CPU2 CPU1 CPU0  Bin  Hex
---- ---- ---- ----  ---  ---
OFF  OFF  OFF  ON  = 0001 = 1
OFF  OFF  ON   OFF = 0010 = 2
OFF  OFF  ON   ON  = 0011 = 3
OFF  ON   OFF  OFF = 0100 = 4
OFF  ON   OFF  ON  = 0101 = 5 
OFF  ON   ON   OFF = 0110 = 6
OFF  ON   ON   ON  = 0111 = 7
ON   OFF  OFF  OFF = 1000 = 8
ON   OFF  OFF  ON  = 1001 = 9
ON   OFF  ON   OFF = 1010 = A 
ON   OFF  ON   ON  = 1011 = B
ON   ON   OFF  OFF = 1100 = C
ON   ON   OFF  ON  = 1101 = D
ON   ON   ON   OFF = 1110 = E 
ON   ON   ON   ON  = 1111 = F 

(Thanks to @Mokubai for pointing this out)

Alternatively, create a shortcut to

C:\Windows\System32\cmd.exe /c start /affinity 1 PATH_TO_EXE.exe
  • 1
    Given that the "start" command CPU affinity is a bit mask (superuser.com/a/309663/19943) simply increasing the value would be problematic and produce unexpected results in many cases. – Mokubai Feb 1 '17 at 7:59
  • @Mokubai, thanks a lot! I've modified the answer. – PulseJet Feb 1 '17 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy