Change Windows Service Priority

Posted by SchlaWiener on Server Fault See other posts from Server Fault or by SchlaWiener
Published on 2010-09-08T12:36:36Z Indexed on 2012/10/16 17:06 UTC
Read the original article Hit count: 251

I have a windows service that needs to run with High Priority.
At the end of the day I want to use this script to modify the priority after service startup:

Const HIGH = 256

strComputer = "."
strProcess = "BntCapi2.exe"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = '" & strProcess & "'")

For Each objProcess in colProcesses
    objProcess.SetPriority(HIGH)
Next

But currently I am not able to change the priority, even with the taskmanger. The taskmananger throws an "Access Denied" error, but I am logged on as administrator and I changed the user account of the service to administrator, too.

I still get the "access denied" message when trying to change the priority. Any ideas what permission I need to do that?

© Server Fault or respective owner

Related posts about windows-server-2003

Related posts about windows-service