How to configure a Windows service process to run with low priority?

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?


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!


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

ChangePriority.ps1

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\""

Attempts 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