Start an Application Assigned to a Specific CPU in Windows Vista
Windows Vista has an option that lets you start an application and set the CPU affinity, which assigns the application to run on a specific CPU in a dual-core system.
To start an application you have to pass the affinity flag to the start utility in the command prompt. For instance, if you wanted to start notepad assigned to CPU, you could use the following command:
c:\windows\system32\cmd.exe /C start /affinity 1 notepad.exe
You can see in task manager that the process is only assigned to CPU 0
To start a process on CPU 0, use the following command switch:
/affinity 1
For CPU 1, use this switch:
/affinity 2
You can use a number up to the number of CPU cores or CPUs in your system. The affinity is essentially CPU core # + 1, so /affinity 5 would use CPU 4.
You can almost modify the shortcut for an item to make it run on the specific CPU, by just prepending the full “c:\windows\system32\cmd.exe /C start /affinity 1 ” onto the shortcut target. The only drawback to this approach is that the command prompt window will briefly flash on the screen.

Daily Email Updates
You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


/affinity 5 does not use CPU 4
1 uses CPU0
2 uses CPU1
3 uses CPU0 and CPU1
4 uses CPU2
5 uses CPU2 and CPU0
6 uses CPU2 and CPU1
7 uses CPU2, CPU1, and CPU0
8 uses CPU3
9 uses CPU3 and CPU0
Convert the number to hex and reverse it to see which CPUs are to be used.
I’m really appreciative of what you have shared with me as I have some applications that I’ve needed to be able to control the affinity of a process that I spawn.
Thanks for your help.
Thanks to for this website. I’ve been work’n /w Vista going on two months and as your all aware. You have to unlearn what you’ve learned. Those older versions of window ie,. xp, xpro etc. have NOTHING on Vista. NO more just editing INI’s is a thing of the past. But Wait There IS MORE! Hope anyone\everyone who aquires a version of vista like to read for this is NOT for the LAZY…..
Thanks
Is there anyway to force this with XP without having to reset the CPU affinity each time you launch the app?
Jason, try http://robpol86.com/pages/imagecfg.php
Originally this comes from the Win2K resource toolkit, so probably safer to get it from there.
It seems that start /affinity works just for some applications. For example by starting firefox with start /affinity 01 firefox.exe the affinity was not set correctly. Could anybody else prove this or have a workaround?
I play with the affinity and priority in XP and feel it improves my performance. In particular, I have Folding and Ghost 12 running in the background most of the time and don’t even know they are there. I put everything that loads during the startup process on one core and lower the priority (with the exception of explorer.exe). This works well for me but I’d be curious if it works equally well for you.
1. Download PROCESS.EXE from http://www.beyondlogic.org/sol.....ssutil.htm
2. Create a batch file – this is part of my batch but it should get you started.
set cpu=10
set speed=Low
process > x:\process.fil
for /f “tokens=2 delims= ” %%v in (x:\process.fil) do process -a “%%v” %cpu%
for /f “tokens=2 delims= ” %%v in (x:\process.fil) do process -p “%%v” %speed%
process -a “explorer.exe” 01
process -p “explorer.exe” Normal
BTW, I use this on Vista and XP.
Mike Honeycutt
sample C:\Windows\System32\cmd.exe /c start “runhigh” /high /AFFINITY 1 “C:\Program Files\Windows Media Player\wmplayer.exe” /prefetch:3 all work’s but how to assign like cpu 1 and 2 to a app greeting’s from the low land’s
anser if you have 4 core,s affinity as follows
1=0
2=1
3=0,1
4=2
5=0,2
6=1,2
7=0,1,2
8=3
9=0,3
10=0,1,2,3 and again greeting from da low land’s
a=1,3
b=0,1,3
c=2,3
d=0,2,3
sample C:\Windows\System32\cmd.exe /c start “runhigh” /high /AFFINITY D “C:\Program Files\Windows Media Player\wmplayer.exe” /prefetch:3
so “affinity D” results in the usage of core 0,2,3
OK I tried this on a game that seems to crash when using multicore but is supposed to be ok if affinity is set to 1 core. The problem is no matter if i do it thru command prompt or by using taskmanager it keeps resetting affinity to all cores. Any ideas or suggestions?
The game also has an option for multicore support but makes no difference if it is on or off
c:\windows\system32\cmd.exe /C start /affinity 1 does not work in XP……..it says AFFINITY is an invalid switch….any other way to do this in command prompt in XP?
Thanks in advance.
Alx
I cam manage to get this working from the commandline… but not from a shortcut….
the target is currently C:\Windows\System32\cmd.exe /c start /affinity 1 “C:\Spill\A Vampyre Story\game\main.exe”
but all I get is a commandline window with “C:\Spill\A Vampyre Story\game\main.exe” as the title…
When you put it in quotes it names the window, try it like this:
target: C:\Windows\System32\cmd.exe /c start /affinity 1 main.exe
start in: “C:\Spill\A Vampyre Story\game\”
Try this http://usuarios.lycos.es/coreaffinity/
When i try to do this in a shortcut with a quad core everything pops up and runs as it is supposed to but when i check taskmgr to see if the process is on all affinities, it is only on 2. What i have is:
Target: “c:\windows\system32\cmd.exe /C start /affinity 10 Wow.exe”
Start in: “C:\program files\world of warcraft\”
How do i make it run on all 4 cores?
lazygamer, it does that because wow only supports 2 cores, and won’t use more…
(you can use the 2 other cores for multitasking or something though)
Nice information but I have apps that load on startup that really slow everything down until they’ve loaded (VK and anti-spyware). They both fight for supremacy over CPU 0 while CPU 1 is idle. This makes the startup take forever.
I’d like to set the affinity before windows starts up instead of after. Seems like I need something like the app Mr X suggested that loads as a service on boot, then configure it to set the affinity of stuff that loads during startup.
Unless someone else knows a way to force this without a bootable app.
Good article! But keep in mind that this is HEX mask and is read from right to left:
i.e.
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 confirmed via task manager
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 confirmed via task manager
ON OFF ON ON = 1011 = B
ON ON OFF OFF = 1100 = C
ON ON OFF ON = 1101 = D
ON ON ON OFF = 1110 = E confirmed via task manager
ON ON ON ON = 1111 = F
Of course, the CPU on task mananager is listed left to right, so now you have to flip all of the above.
HEX 30 = Binary 110000 = CPU5 CPU4, but I ONLY have a quad core, so I cannot confirm this works or not.
Then create a .BAT file that contains this command to start the app on CPU1 and CPU3:
REM MY BATCH FILE
START/AFFINITY A .\”some executable name.exe”
Where .\ denotes the current directory, and if there are any spaces between the names, put the whole thing in “”.
If you need to add /D and full path:
REM MY BATCH FILE
START/AFFINITY A /D C:\”Program Files”\”some app folder” C:\”Program Files”\”some app folder”\”some app.exe”
Notice that each folder names are encased in “” betwen the \’s. From my experience I found this following does not work:
START/AFFINITY A /D “C:\Program Files\some app folder” “C:\Program Files\some app folder\some app.exe”
You can create a shortcut to the batch file, and right click and select “Run As Administrator” as needed. It’s too bad the START command doesn’t offer this option…
Now script/batch till you drop!
It would be nice to find out if we can set a parameter in the registry for this. Some programs run on boot and it can be helpful in some cases to have them on different processors.
For example, when my system starts up, it loads AVG and Spybot which both take a lot of processing resources during startup resulting in a very slow start while they both wrestle for dominion over the processor time. Since they will both use processor 1 as a default, processor 2 remains idle. Being able to define the default processor for these applications at boot up would eliminate a lot of this contention and streamline the boot process.
Unfortunately, these sort of programs cannot be executed from a batch process to load on startup… Or can they?
I tried using c:\windows\system32\cmd.exe /C start /affinity 1 “C:\Games\SimCity 4\Apps\Simcity 4.exe”, but it just opens a command prompt window with the name SimCity 4 and the exe’s folder displayed to the left, never actually opening the game.
@Sam
Take out the space you put between START and /AFFINITY
There should be no space there and it will also cure the invalid switch errors too for XP users.
You can also have a batch file to do it. Create a text file in the game directory where simcity4.exe is and rename it to simcity4.bat.
edit into the batch file the following line:
START/AFFINITY 1 .\SIMCITY4.EXE
Now use the batch file as a shortcut to run the program. I know this works since I use it to run Everquest when I run both my accounts on two monitors at once.
Thanks, but it still opens the DOS prompt. I tried c:\windows\system32\cmd.exe /C start/affinity 1 “C:\Games\Maxis\SimCity 4 Deluxe\Apps\Simcity 4.exe” The batch file produced the same result.
I doubt any of you (the ones are having problems with the DOS prompt and the ones with the “invalid switch”) would be able to make it work, with the “space” or without it. The reason I suspect is because it only works on vista and up (windows 7 probably) but it doesnt under XP. A simple “start /?” from the command line would show you if it accepts that parameter. Good luck with it!!
this should work on ANY system that is newer than XP, and i dont see why you couldn’t copy the cmd.exe from a vista machine and use it (dont overwrite the xp cmd.exe, rename the new one to cmd2.exe or something before you copy it)