How to restrict windows service to X cores?

Posted by Martinnj on Super User See other posts from Super User or by Martinnj
Published on 2012-11-26T11:08:25Z Indexed on 2012/11/26 11:10 UTC
Read the original article Hit count: 154

I'm currently trying ot figure out a decent/nice way of determening what core(s) a single service should run on, in Windows Server 2008.

I'm aware that for procceses there is two ways to do it:

  1. set affinity through task manager after proccess is launched.
  2. use "start /AFFINITY 0x1" or similar bitmask

However this does not seem to work very well with services. When i try to launch the exe that the service will also run (the one that needs restriction) it just spawns a new commandline (and starts the process) but the process terminates shortly after.

Does anyone here know how to do a similar trick for services? It is not important what core it is running on, it just needs to be restricted to only one. And preferably it should be something that can be automated, so we do not have to interfere when there is a server restart.

© Super User or respective owner

Related posts about automation

Related posts about Services