How do I set the group and affinity of a Windows executable from the command line

You can use the /affinity flag using the start command to specify the cores a process should use.

Usage

start /affinity n foo.exe -arguments

So, your shortcut would look like:

c:\windows\system32\cmd.exe /C start /affinity n foo.exe -arguments where n is CPU core number +1.

So to run on Core 0 it'd be:

c:\windows\system32\cmd.exe /C start /affinity 1 foo.exe -arguments.

Source

Specifying multiple cores

Assume a CPU has 4 cores. To specify the cores to use:

  1. Visualize the cores as an array with the length of the array equal to the number of cores. The cores will be arranged in descending order from right to left:

    [CPU3, CPU2, CPU1, CPU0]

  2. Now, replace cores you would like your process to use with 1 and those you won't with 0. Assuming I want my process to use core 3 & 1, my array would like this:

    [0,1,0,1]

  3. "Pop" the elements of the array to a string. Now it would be represented as 0101.

  4. Assume the string is in binary and convert it to hexadecimal. Now it would be 0x5

  5. Now use the same command start /affinity n foo.exe -arguments but now n will be 0x5, giving start /affinity 0x5 foo.exe -arguments

Source

Notes:
  • The source explains the visualization as a binary string, not an array( check it out). I find this a bit confusing so I explained using an array.
  • The source does not specify that you must prefix 0x to show it's hexadecimal in the command. Reading start /? specifies it is to be hex.