Windows Service Process Thread Priority Affinity

In Windows, each running 'Service' or 'Process' can have any of these process 'Priority Class' levels, and, all running 'Thread(s)' for/under a 'Service' or for/under a 'Process' can have any of these thread 'Priority Class' levels, their code/number equivalance are also shown below:

|  Priority    | Process | Thread | Base Process | Thread  |
| Class Levels |  Prio   |  Prio  |   prio in    | prio in |
|              |         |        |    PE, PH    | PE, PH  |
| ------------ | ------- | ------ | ------------ | ------- |
|  RealTime    |  256    |  15    |  24          |         |
|  High        |  128    |  2     |  13          |         |
|  AboveNormal |  32768  |  1     |  10          |         |
|  Normal      |  32     |  0     |  8           |         |
|  BelowNormal |  16384  |  -1    |  6           |         |
|  Idle        |  64     |  -2    |  4           |         |
|  Lowest      |  N/A    |  -15   |  N/A         |         |

In some Edition of Windows, some of such features may not exist or not-available or not-applicable . PE = Process Explorer . PH = Process Hacker . prio = Priority.

Use GUI utilities/tools

Windows Task Manager

Start Windows Task Manager like this:

ntsd -c qd taskmgr.exe

Then click on "Processes" tab > select "Show Processes from All Users" option > find 'unbound.exe" in process list & select it > right click on it > select "Set Priority" > select or click on "BelowNormal". Again right click on "unbound.exe" > select "Set Affinity" > select only 1 CPU, if you see tick/check mark next to all CPUs > 'OK'. Close Task Manager.

Process Explorer / Process Hacker

You can also use "Process Explorer", "Process Hacker" type of GUI utilites/tools as well to change 'Service', 'Process' priority class levels, thread priority class levels, processor core affinity, etc.

Process Lasso

This GUI utility program is still free, get it from here. After decompress and run the setup. During install, select "Start at login for all users", for both Management Console & Core Engines, select "Manage processes for all users", select "Use a custom file system location" option for saving config-settings & log files.
First click once on the "rude" or "unsmart" process or service software, which is not behaving properly, or does not behave the way you want it to be, or does not have the configuration option/feature(s) to select CPU cores, process priority, thread priority, etc. Day by day, there will be more and more CPU & GPU & CryptoPU & other types of micro-processing-units or processor-modules packaged/integrated inside one physical CPU/Processor.
Right click on the service/process which you want to manage, go inside both of these two options (1) Default CPU Affinity (2) Current CPU Affinity, and each time select same options for both: you may select CPU 0, or CPU 1, or unselect CPU(s) which are not to be used by this service/process, and also click once on "No Default Affinity".
Right click again on that proces/service, now go inside both of these two options (1) Default Priority Class (2) Current Priority Class, and each time select same options for both: you may select "Below normal", "Above normal", etc, and also click once on "Windows Dynamic Thread Priority Boosts Enabled" option, to unselect it or to remove check-mark or to remove tick-mark from it.
If the process/service is still not behaving the way you want it to, then: right click on it & select: Less Common Actions (Hard Throttle) > go inside both of these options (1) Default Hard Throttle Level (2) Current Hard Throttle Level, and each time select same options for both: you may select "Lowest", "Low", "Moderate", "High", etc.
If that app or service uses too much cpu/ram resources then choose less CPU affinity, choose high or higher throttle option, choose below normal priority, etc. If you want to assign more power & resource for it then select Higher Priority and no throttle and no default affiity. And/or adjust/customize further for better result.


There are script/batch file as well to pre-control automatically priority & affinity for processes, threads.

Set Running Service/Process Priority using Script

A vbs / wmi script:

  Const BELOW_NORMAL = 16384
Set objLoc = createobject("wbemscripting.swbemlocator")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colServices = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Service where name='vidalia'")
objLoc.Security_.privileges.addasstring "sedebugprivilege", true
For Each oService in colServices
Set colProcesses = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Process where ProcessId=" & oService.ProcessId )
For Each oProcess in colProcesses

a powershell script:

  (gps -id (get-wmiobject win32_service where {$ -eq "vidalia"}).ProcessId).PriorityClass="BelowNormal"

more info : Set Priority of Win32_process class MS-Win

Set Running Service/Process Affinity using Script

Using powershell script like below, find all running "vidalia.exe" process/service, and set or associate each one's processor core affinity with the first CPU (CPU 0):

  $vidaliaSet = Get-Process -ProcessName "vidalia.exe"
foreach ($vidalia in $vidaliaSet) {$vidalia.ProcessorAffinity=0x1}

If you are running multiple Vidalia, and you want each to use different CPU core, then perhaps you should pre-configure: by renaming vidalia.exe to vidaliaN.exe, where N is 0~9 digit, inside multiple different "Tor Browser\App\" folders, and you have used some batch (bat, cmd) or script to start/run multiple Vidalia (Tor proxy server controllers).

Begin a Process & Also Set Priority & Affinity

On Windows 2003/2008 Server, Vista, 7, 8, these existing commands or Microsoft (MS) tools or 3rd party tools can be used to set affinity & priority:

  start /affinity 1 /BELOWNORMAL vidalia.exe
psexec /a 0,1 vidalia.exe

Note: the '/affinity' option of start command, it is not supported in Windows XP.

Use WMIC & Task-Scheduler To Set Running Process/Service Priority

In Windows XP (Professional), Vista, 7, 8, Server 2003/2008, you can do this: Goto windows Start Menu > All Programs > Accessories > System Tools > run 'Scheduled Tasks' . Double click or run 'Add Schdelued Task' > Next > Browse into "C:\Windows\system32\wbem\" folder and select the "wmic" or "wmic.exe" file > click on 'Open' > Now change task name from "wmic" into: "wmic process vidalia.exe setpriority BelowNormal" (do not use previous double quote symbols inside the Task-Scheduler program, used only to wrap the line to show you on this webpage) > Select 'Daily' for 'Perform this task:' option > 'Next' > Skip 'Start time:' > Perform this task: Every Day > Skip 'Start date:' > 'Next' > In (Run as) user name text box you will see YourComputerName\YourWindowsUserAccountName > Change that user name text string into "NT AUTHORITY\SYSTEM" (Do not use previous double quote symbols, and leave below password fields empty) (Alternatively, you can change only the user account name portion shown after your computer's name and the \ (back-slash) sign, then specify such an user account name who has membership of 'Administrator' group, and enter twice that Administrator type of user's password > 'Next' > 'Finish'. In 'Scheduled Tasks' window, right click on item named "wmic process vidalia.exe setpriority BelowNormal" > Select 'Properties' > In 'Task' tab > Change Run: textbox's value from "C:\WINDOWS\system32\wbem\wmic.exe" into below mentioned value:

  "C:\WINDOWS\system32\wbem\wmic.exe" process where name="vidalia.exe" call setpriority 16384

Then goto 'Schedule' tab > 'Advanced' > Select & check mark on 'Repeat task' option > Change 'Every:' from 10 mintues, into 15 minutes (or more) > Change 'Duration:' from 1 hour(s), into 24 hour(s) > 'OK' > 'Apply' > You can either specify: YourComputerName\AnAdministratorUserAccountName in 'Run as' and that user's password twice, or, you can specify: NT AUTHORITY\SYSTEM in 'Run as' and leave passwords fields empty > 'OK' > 'OK'. You may now close 'Scheduled Tasks' window. Now windows scheduler will automatically set the vidalia.exe service priority into 'BelowNormal' mode, so that it uses lesser amount of CPU resources.

Use ProcAff & Task-Scheduler To Set Running Process/Service Affinity

Get ProcAff (Processor Affinity, by Stefan, from here). Decompress the zip file. Copy the "procaff" folder inside "C:\Program Files\" folder (or inside %ProgramFiles%). Change/rename "procaff" into "ProcAff" folder. Copy both "C:\Program Files\ProcAff\release\procaff.exe" file & "C:\Program Files\ProcAff\x64release\procaffx64.exe" file, into "C:\Program Files\ProcAff\" folder. Then, like previous/above section (using wmic & Task-Scheduler to set process/service priority), create another new scheduled task for the "procaff.exe" (or for the "procaffx64.exe" based on your system's bits). Follow all steps exactly like above, but, change when you reach these two areas : change task name from "procaff" to this "ProcAff set CPU 1 vidalia.exe", and, change "Run:" textbox's value from "C:\Program Files\ProcAff\procaff.exe" into below value:

  "C:\Program Files\ProcAff\procaff.exe" /set 1 vidalia.exe

Then fine tune further by doing this: find previous section's exact Start time: or "Schedule from" time, and, set/change this task's "Schedule from" or "Start time", just 1 or 2 minutes ahead/earlier of that task's time. Then this task will automatically set processor affinity just 1 or 2 minutes before the previous section's priority setting task.

If you run multiple Vidalia, then perhaps a 'for' loop and PIDs from 'pslist' for all running vidalia and an incremental affinity counter can be used, to apply 'ProcAff' for setting diferent core on different vidalia.

  • Another tool, 'imagecfg.exe', found inside 'Windows Server 2000 Resource Kit Supplement utilities', can also be used on any Windows, to set processor affinity of running 32bit processes & services.

Run/Begin Vidalia As Service With Lower Priority & Affinity

Create a customized or another vidalia service which will start automatically when windows starts up, and also force it to use very specific CPU core affinity & priority from very beginning : Open/run a "Command Prompt" (it will be better if you start it as Adminitrator).

By Using instserv srvany etc MS tools

On Windows NT, 2000, XP, Vista, 7, 8, Server 2003, 2008, 2012: If you yet do not have 'Windows NT/2000/2003 Resource kit utilities' then get it from here (rktools.exe: 12,337,752 bytes, SHA-1: 3F3878FFB2C642E752D811DC05169BFCC2AA97B5). if you are using Windows here present or get it to use on Windows XP, Server 2003, Vista, Server 2008, on your Windows (), thwhich has 'instsrv.exe' & 'srvany.exe' & 'sc.exe', etc. Run/open a "Command Prompt" window as an Administator user, goto the folder (C:\Program Files\Windows Resource Kits\Tools\) where you have installed resource kit, follow like below:

  C:\Documents and Settings\MyUserName> cd /d %ProgramFiles%\"Windows Resource Kits\Tools\"
C:\Program Files\Windows Resource Kits\Tools\> instsrv.exe "Vidalia_2" "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"
...> reg add /?
...> reg add HKLM\SYSTEM\CurrentControlSet\Services\Vidalia_2\Parameters
...> reg add HKLM\SYSTEM\CurrentControlSet\Services\Vidalia_2\Parameters /v Application /t reg_sz /d cmd.exe
...> start /?
Note: On Windows Vista, 7, 8, Server 2003/2008, execute next command-line:
...> reg add HKLM\SYSTEM\CurrentControlSet\Services\Vidalia_2\Parameters /v AppParameters /t reg_sz /d "/c start /affinity 1 /BELOWNORMAL \"C:\Program Files\Tor Browser\Start Tor Browser.exe\""
Note: On Windows XP, execute next command-line:
...> reg add HKLM\SYSTEM\CurrentControlSet\Services\Vidalia_2\Parameters /v AppParameters /t reg_sz /d "/c start /BELOWNORMAL \"C:\Program Files\Tor Browser\Start Tor Browser.exe\""

If you have an instance of "vidalia.exe" process (or service) already running, then by using the Windows "Services" manager (in "Run" window (press WindowsFlagLogo+R buttons to start this window), type: services.msc ?), if you can see new service "Vidalia_2" exist in list, then stop the other vidalia service either by selecting "Vidalia" service from list, and set to 'Disable' or 'Manual' startup mode, or unselect the Run as Service option inside the Vidalia Control Panel. Then right click on "Vidalia_2" service > 'Properties' > in 'General' tab > change 'Startup type:' to 'Automatic', if its not already set to that > OK. Right click on "Vidalia_2" service again > click on 'Start' or 'Run'. If you use Windows XP, only then see & apply above section which shows info on How to use "ProcAff" & Task-Scheduler tools to set processor affinity. Get more info on commands & functions which are used on this section, from here, here, here.

By Using Winserv tool

On Windows NT, 2000, XP, Vista, 7, 8, Server 2003/2008/2012, the "Winserv.exe" tool can also be used to create a service for another service or for an application, and configure to start with lower priority & reduced affinity. Get Winserv (from here, [here]. Copy "winserv.exe" file inside the C:\Program Files\Tor Browser\App\ folder, where the "vidalia.exe" file exist.

  ...> "C:\Program Files\Tor Browser\App\winserv.exe" install "Vidalia_3" -displayname "Vidalia, a Tor Proxy Server Controller" -start auto "start /affinity 1 /BELOWNORMAL \"C:\Program Files\Tor Browser\Start Tor Browser.exe\""

On Windows XP, do not use the /affinity 1 portion shown above, see & apply instruction from few section above, which shows info on How to use "ProcAff" & Task-Scheduler tools to set processor affinity.

By Using SC tool

On Windows NT, 2000, XP, Vista, 7, 8, Server 2003, 2008, 2012, the 'SC' tool can be used to create service. SC tool is included in Resource Kit. More info here.

By Using psexec tool

The 'psexec' tool, can also be used to start an application as a process, and can be used with Task-Scheduler, sc, srvany.

Start/Stop Service/Process On Non-Admin Windows User

To start or stop a windows service from a non administrator user account, follow & adjust user Sach's answer, from this page. If the full link does not work, then use from beginning upto 'questions/4436558/' portion (without using single quote symbols which are used here only to inform you on that specific portion).


WSRM (Windows System Resource Manager) found on Windows Server 2003 enterprise, 2003 datacenter, Server 2008, can set process & service priority, affinity, per-processor core utilisation settings, which will persist across reboots.


By Bry8Star. Copyright (c) 2012 Bry8Star (bry8 star a.t ya hoo d.o.t c om).

  • Disclaimer: If you make mistake in following, any of these "general" steps/guidelines mentioned here in these article, it will NOT be good at all for your system, so be warned, search for each word which you don't understand, on Bing / Yahoo / Google search engine sites and search in documents and books, before actually following any of these steps. Instruction writer(s) has(/have) tested and found these steps to be effective on his/her(/their) computer's OS + software + hardware + internal-network + external-network, etc environment + configuration + settings + features + restrictions, etc combinations. These factors cannot be 100% same on your case. Instruction writers are assuming, users who will follow these steps are familiar with these steps, at least have done such once or twice before and very recently, effectively and correctly. Instruction writer will not be (and cannot be held) responsible in any way for your mistakes, or for your lack of experties, or for your lack of understanding, or for your lack of not following these general instructions, or for not converting them to a practical level in correct manner for your case, or for not learning effectively more on these, or for not realizing the patterns to suit/modify with/for your case, or for any conflict or for any type of any loss which may or will occur with any current or any future component / event / etc. Everything is changing all the time, so you will need to improve & adopt better solution(s) which suits you, your need(s), that is your responsibility. Adopt such solution(s) which is(/are) (or will be) better for majority, or will meet your goals. Adopt which works, discard which does not.

Last modified 5 years ago Last modified on Sep 9, 2012, 6:19:14 AM