Sign in with
Sign up | Sign in
Your question

Set CPU Affinity prior to app launch?

Last response: in CPUs
March 19, 2007 11:01:35 PM

For the life of me, I can't remember how to set CPU Affinity for an application BEFORE it launches. Changing it WHILE the app is running is easy but I don't want to always have to crtl-alt-del into Processes to change AFTER I run the app.

I have an app that wants to run on CPU 0 and not CPU 0/1. So I got CPU 0 @ 100% and CPU @ 15% or something. I've put " -cpu 0 -cpu 1" at the end of the target line, but that doesn't work. I can't remember the proper syntax....argh.

What's the proper syntax/methodology to Set Affinity on Target line?

Much thanks.
March 19, 2007 11:30:41 PM

I would also appreciate the answer to this! Great question.
March 19, 2007 11:49:14 PM

I did a ton of farking research on this. I could not find a clear solution.

If anyone knows the answer I too would greatly appreciate it.
Related resources
Can't find your answer ? Ask !
March 20, 2007 12:10:10 AM

Until now, I didn't know you could set affinity of any program from Task Manager. :oops: 

I'd love an answer to this as well. It would be nice to have all processes run on one core and your games on the other without having to manually set the affinity each time.
March 20, 2007 12:51:21 AM

Add me to the list of the curious...
March 20, 2007 12:58:53 AM

LMAO. Well now I don't feel like such a noob. I guess if ya gotta ask a question, better make it a good one, eh? ;) 

Ya, you can set affinity from Process in Task Manager, but it's WHILE the app is running.

Someone, somewhere, at sometime.....told me how to do it, but I've long since forgotten :oops: 
March 20, 2007 1:05:15 AM

March 20, 2007 1:10:24 AM


Can we get a 6th??? ;) 
March 20, 2007 1:18:46 AM

I thought there was an application one had to download which would change the beginning of the executable to make it permanently on one core or the other. It would probably break things if you ever tried to run a patch on the program though (without changing back to the original executable first).
March 20, 2007 1:44:18 AM

As far as I know, there are no way to preset affinities with Task manager.

I think this is the application to set affinity that you're mentioning.

I'm linking to the official source here:

Also a google caché of the same page because AMD forums were under repair at the moment...

I read in that site that now you don't need to modify the exe to make it work. I sincerely didn't test it so don't complain if that program misteriously wipes out all your pr0n. I can't find mine, thats for certain. (??)

Hope it helps and as usual, sry for my english!
March 20, 2007 4:32:11 AM

I heard duct tape works with bailing twine and a shot of whiskey for the user.Other than that I have no clue but I did make a tape and twine ball and used it as a trash can ball as i was getting drunk. :D 
Was that before or after you bent the pins installing your 3200+? :o  :oops:  :oops:  Sorry Vern....i'll can it with the pin jokes, from now on. :wink:
March 20, 2007 11:05:52 AM

here's another one

PS: i never tested any of them so watch out for eventual threats
PS2: they got the source code so i guess you can check if it's safe.
March 20, 2007 11:26:29 AM

There's a program called Launch & Set (although the link seems to be down at the moment) which allows you to set the affinity of a program to either or both cores before you launch it. It's only a small program (about 60k) so drop me a PM with your email if you want a copy. If I get too many requests I'll upload it and send you a link instead.
March 20, 2007 12:00:13 PM

I always used "Firedaemon" myself for this specific purpose, well at least for starting my game server on specific cores. Never tried it with any regular applications.
March 20, 2007 3:49:39 PM

Wow, thanks for the responses!

Ford, I've sent you a PM so you can email me that prog to try seems simple enough.

I'll try that first and see how it goes. Maybe look into SSS's suggestions.

Much apppreciated, great help.
March 20, 2007 4:39:00 PM

hmmm...I'm kinda tempted to write a little tray app that lets you add processes to a list and auto changes their affinity and priority. Really should be doing my own work tho!

That imagecfg link is interesting. Not sure how it works, I can't remmeber if there is a var for affinity in the PE headers or not.
a b à CPUs
November 20, 2008 7:56:03 PM

Yea. The THG Task Assignment Program is very usefull. I have used it often recently, as long as TaskAssign.exe is running in memory (Assuming you have already Set Processor Affinity) it will run the Specified Application(s) in it's App List, using the processor you have specified.
a b à CPUs
December 11, 2008 11:52:00 AM

Hi! check this tool I made
a b à CPUs
December 11, 2008 1:06:24 PM

I would ordinarily remind people that downloading and running files linked by new registrants is quite a bit less than wise. But here at Tom's we are smarter than that...


Oh mah... I kill myself sometimes... :D 
a b à CPUs
December 12, 2008 7:51:50 PM

If you dont't want people to help in this forum, just say it; and in order to prevent other users, first check if you are right or not with that kind of affirmations. I'm offering for free a software of my property, and I think I deserve a little of respect. So, if you don't trust, the answer is easy: don't click.
One more thing, I just registered to post this link to give people a solution that I made for myself, and I wanted to share it. Perhaps, Scotteq, you're not as smart as you pretend to. No more to say.
October 25, 2009 8:49:19 AM

I know this is an old thread, but here's the easy answer that didn't come up. WinXP (and also Vista, I believe) has a utility included called start. This utility can be used to run a program with a specified cpu affinity. the command would look like this:

start /affinity xx myprogram.exe

Use the actual name of the program you want to run, of course, and substitute xx for a hex number representing the affinity you want as follows:

01 - 1st CPU
02 - 2nd CPU
03 - 1st and 2nd CPU
04 - 3rd CPU
05 - 1st and 3rd CPU
a b à CPUs
February 7, 2010 4:32:52 PM

please let me know more, im trying to run silent hill 2 on 1 cpu but cant set it from task manager as i get an error. where is this utility in vista? goto run? thanks. Ben
a b à CPUs
March 26, 2010 8:01:21 PM

Found this while reading for issues like this.

For windows 7, not sure with other os.

Create shortcut of app.
Right click on shortcut.
Target line:C:\Windows\System32\cmd.exe /C start /affinity 1 C:\(ProgramFolder)\(program).exe

(1 can be changed depending on the affinity you wish to set)
April 16, 2010 9:43:19 AM

well i use win7 and that doesnt work for me,
What i am trying to do is make a program use both cores for smoother sailing

C:\Windows\System32\cmd.exe /C start /affinity 0 1 C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe
(modified command line to set sam using the two cores)

C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe
(is the original command line)
a b à CPUs
April 16, 2010 11:57:40 AM

You can do this by modifiying a programs launch options. Theres also a few third party apps that do this (Forcecore, etc).

Problem is, don't try to be smarter then the Windows scheduler. Forcing the issue will probably cause a performance loss in the long run.
April 30, 2010 12:29:14 AM

Orion1977 said:
well i use win7 and that doesnt work for me,
What i am trying to do is make a program use both cores for smoother sailing

C:\Windows\System32\cmd.exe /C start /affinity 0 1 C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe
(modified command line to set sam using the two cores)

C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe
(is the original command line)

Orion, your command line should read:

C:\Windows\System32\cmd.exe /C start "" /affinity 3 "C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe"

I've added the quotes for clarity. I'm not sure if it likes spaces in paths. I've added the first set of quotes because Start will annoyingly use the first set of quoted text as the title.

The affinity should be a single hexadecimal number, not a list of CPU numbers:
1 = use CPU 0
2 = use CPU 1
3 = use CPU 1 and 0
4 = use CPU 2
F = use CPU 3, 2, 1 and 0

EDIT: I forgot to say, all applications use all CPUs by default. It may by that SAMBC has not been designed to take advantage of multi-core processors, in which case there's nothing you can do to force it to run on both. It will have access to both, but will only use as many as it wants to.
August 7, 2010 3:20:40 AM

Would there be a way to run EVERYTHING on core 0 unless specified otherwise? For example on my brother's laptop, it would be convenient to run everything on core 0, maybe winsystem on core 1, and then if he's dual-boxing World of Warcraft he can have a wow.exe on core3 and a wow.exe on core4

Any ideas?
August 7, 2010 5:01:59 AM

I doubt it, and frankly I'd be surprised if that was in any way a good idea. I may be wrong, but that just sounds like a control-freak idea (which I'm good at too) that's going to cause more problems than worth.

Many programs now have multi-core support and will run across all four cores. By limiting a process to one core, you're essentially denying it access to three-quarters of your processing power. Processes that aren't busy won't use a significant amount of processor power anyway.

The only way I can think to achieve your idea is to find a way to force everything to run on core 0. They you can set up individual applications to use a particular core using the suggestions in the previous posts. The trouble is, I don't know of anywhere in Windows where you can set default affinity settings.
August 8, 2010 1:59:11 PM

How about linux? I'm playing with various distros now in VMware, deciding which one to dual boot with 7 when I install it.
August 8, 2010 2:01:45 PM

And the only reason why I ask that is if my system ran fine on a single athlon 64 3000+ (2.6-2.8ghz i think?) playing video games, then why shouldn't I be able to run everything BUT my games on 1 of my 3.0ghz cores? I'm probably not understanding computing logic here, but in my mind if I have 4 3.0ghz cores why shouldn't I be able to run everything the way I used to on my old computer on one core, and then run games on a second, and virtual machines on 3rd and 4th