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?

link|improve this question
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
feedback

3 Answers

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!

link|improve this answer
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
feedback

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] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/WAIT] [/B] [command/program] [parameters]

link|improve this answer
feedback

start /low or cmd.exe start /low will not work because the service needs to receive a message from the system that the service was started succefully, and start or cmd will not send this "ok".

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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