Is there a way to configure a Windows service process (e.g. squidNT, SQL Server, etc) to start automatically with low priority without manually changing process priority via Task Manager?

  • Changing the priority of threads or processes is usually a bad idea, unless the code has been written to run at a different priority. Changing priorities adds "priority inversion" to the list of concurrency issues to avoid. – Richard Sep 21 '09 at 9:12
  • 1
    The OP did not ask if it was a good idea or not. The OP asked if it could be done, and how. -- Please remember to stay on topic. 😉 – BrainSlugs83 May 21 '19 at 21:42

The Service Control Manager, which handles starting / stopping services, doesn't have any mechanism (in any version of Windows heretofore) to specify the priority on processes it starts.

Since you can modify the priority on an already-running process, your best bet might be to use a tool to do that.

I'm not aware of a Microsoft command-line tool to modify process priority, but the "PV" command-line too, available at http://www.teamcti.com/pview/prcview.htm has a function to set priority.

pv -pb process-name.exe

That would set "process-name.exe" to "Below Normal" priority.

If you can live with the process starting out at "Normal" priority until you get around to changing it, you could do so with a script running as a "Scheduled Task" to fire off every-so-often (in case the service gets bounced).

It's a quick and dirty hack, but I owe a lot of my fortune in life to quick and dirty hacks that get the job done!

  • Maybe run a batch file to start the app and then set the process priority, with perhaps a short sleep in between, rather than running the app directly and then running another task to set the priority. Won't work for everything but worth a try. – John Gardeniers Sep 21 '09 at 2:38

Above answers didn't work for me. I ended creating the following powershell script:


Get-WmiObject Win32_process -Filter 'name="ProcessName.exe"' | ForEach-Object {$_.SetPriority(128)}

And then I created a scheduled task that call it every 5 minutes. From Administrator prompt or batch script:

schtasks /Create /tn "Process Priority Change" /sc MINUTE /mo 5 /ru SYSTEM /tr "powershell -noprofile -executionpolicy bypass -file \"%cd%\ChangePriority.ps1\""

Attempted to use wmic as discussed here to make the scheduled task not depending on file failed. Similary using the powershell script: I was not able to just create a single command that just create a task with the inline script. Appreciated if you managed to do it and add another answer.

Values for priority in the powershell script can be found here[1].

[1] https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/setpriority-method-in-class-win32-process

  • Very useful. I chopped up a line with my poor ps skills to set the audio service containing service host process to realtime to prevent audio crackling during heavy cpu usage (bad drivers, I guess). Works great! – JasonXA Dec 7 '19 at 12:43
  • @JasonXA You're welcome. Appreciated if you can provide a one line version of it, which I couldn't – ceztko Dec 8 '19 at 14:22
  • Sure: PowerShell.exe -noprofile -executionpolicy bypass -command "& { Get-WmiObject Win32_service -Filter \"Name = 'AudioSrv'\" | ForEach { Get-WmiObject Win32_process -Filter \"ProcessId = $($_.ProcessId)\" } | ForEach-Object { $_.SetPriority(256) } }" I don't know how right it is... but it works. I haven't managed to make it work hidden, can work only under user w/ admin priv. – JasonXA Dec 9 '19 at 15:17

The following might also work. Edit the ImagePath registry key, and use the start command from cmd.exe:

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/WAIT] [/B] [command/program]
  • Unfortunately this doesn't work at all since the executable launched in ImagePath must respect the interface for Windows services, and start doesn't implement nor it won't route this to the executable being launched. – ceztko Apr 14 '19 at 12:23

I had to do that to make teamcity take less cpu. And, because teamcity is the only java app we are running, that solution works perfectly.

  1. Set service as startup "manual".
  2. Create a batch file, that will start your service, and lower the priority, like:

    net start tcbuildagent
    net start teamcity
    wmic process where name="java.exe" CALL setpriority "below normal"

  3. Create a "task scheduler" job, triggered at "windows startup", that will launch that batch file.

I configured the TaskScheduler trigger with a 1 minute delay, to not interfere with other services starting.

p.s. you can also set all your services startup as manual, and use that batch file to start all of them in the order you want! SQL, IIS, etc.


You could the following powershell script, put it in a scheduled task that runs at startup.

do {
    start-sleep -s 5
    $obj = Get-WmiObject Win32_process -Filter 'name="processname"'
} while ($obj -eq $null)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.