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



As an IT admin, you may need to set the group and affinity of a Windows executable from the command line. This article will provide a step-by-step guide on how to accomplish this.

The first step is to launch the Command Prompt window. To do this, press the Windows key, type cmd, and click the Command Prompt icon.

Once you are in the Command Prompt window, you will need to enter the following command:

tasklist /svc /fi \imagename eq \

Replace the with the name of the executable file you want to set the group and affinity for.

After entering the command, you should see a list of all the processes running with the same name as the executable. The list should also include the PID (Process ID) of each process.

Once you have the PIDs, you need to run the following command for each PID:

wmic process set affinitymask=

Replace the with the process ID of the executable and the with the new affinity mask you want to set for the executable.

The affinity mask is a hexadecimal number that determines which processor cores the process should be allowed to run on. The mask is made up of a series of hexadecimal digits, each corresponding to a processor core. A 1 in the digit means that the process can run on the corresponding core, while a 0 means that the process is not allowed to run on the core.

For example, if you want the process to be allowed to run on the first two processor cores, then the affinity mask would be 3 (binary 11).

Once you have set the affinity mask for each process, you can use the following command to set the group for the executable:

tasklist /fi \imagename eq \ /v /fo list

This command will list the PID, affinity mask, and the group that the executable is running in. If you want to change the group, you will need to use the following command:

tasklist /svc /fi \imagename eq \ /set /group

Replace the with the name of the group you want to set the executable to run in.

Once you have set the group for the executable, you can use the following command to verify the settings:

tasklist /svc /fi \imagename eq \

The command should list the PID, affinity mask, and group of the executable. If the settings are correct, then the process should be running in the group you set.

Setting the group and affinity of a Windows executable from the command line is a relatively straightforward process. All you need to do is launch the Command Prompt window, find the PIDs of the processes you want to set, set the affinity mask for each process, and set the group for the executable. Once the settings have been applied, you can use the tasklist command to verify that they are correct.

Inquire Now

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Find your next full or part-time role here

ScaleDesk can either help you find your next full time gig or a part time side gig where you can create extra income!

Onboard with us once
Skip HR screening and go to the final interview with with only your resume and a video interview you never have to redo
Get paid electronically every month for the hours you work
We will be your reference even if you work for us once

IT Teams: Use ScaleDesk to augment your team

Schedule Demo