Setting the priority for a system service on boot

I'm trying to ensure that a newly installed system service does not steal resources from other more important services.

To achieve this I have attempted to modify the ImagePath key within the app's Registry entry in services

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName\

My entry looks like this 

"c:\windows\system32\cmd.exe"/c start "name" /belownormal "pathtoservice.exe" -c "configpath"

However this does not work, resulting in a short flash of a window (no readable error) when run from CMD, and when entered into ImagePath It simply results in an error saying the program didn't / can't respond to "start or control"

I'm assuming this is because I'm not setting a launch parameter so much as I am handing the first executable over as the application which is to be controlled and since CMD isn't a service nor is start a container for a service, this simply doesn't work

However I haven't been able to locate an alternative, any and all suggestions welcomed. 

Answer
Answer

Hi,

 

Thank you for writing to Microsoft Community Forums.

 

You can start Windows Process on different priority settings, with PowerShell command.

 

Try the below command

 

Get-WmiObject Win32_process -Filter 'name="Process-Name"' | ForEach-Object {$_.SetPriority(Priority-Level)}

 

OR

 

wmic process where name="Process-Name " CALL setpriority Priority-Level

                                                                                                                                

Process-Name will be the process that you want to run e.g. notepad.exe, cmd.exe, etc.

Priority-Level are the level of priority you want to set from high to low, e.g. Low=64, Below Normal=16384, Normal=32, Above Normal=32768, High=126, Realtime=356.

 

Below is the example to start notepad and calculator with high priority.

 

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

 

OR

 

wmic process where name="calc.exe" CALL setpriority 128

 

 

You can create a bat file of the program that you want to start with low priority and put it under shell:startup this will run the bat file every time you boot the system, to do this.

 

  1. Press Windows + R key on your keyboard together.

  2. Type Shell:Startup on the Run window and hit enter.

  3. Copy the bat file you created and paste in on startup.

  4. This will run the command each time Windows starts.

 

As your question is more suitable for TechNet, I would also suggest you to post your question on TechNet forums.

 

Hope it helps.

 

Amit Sunar

Microsoft Community - Moderator

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated May 3, 2024 Views 3,962 Applies to: