Hello,

I have a service that I need to change from running as LocalSystem, to a domain user. If I manually change the service name and password, it works great. However, if I use my new found VBS knowledge (Thanks Robo Scripter!) to do it, it fails when trying to start with the error "The service does not have the correct authentication to run on the system" (Err #15). I confirmed that it at least changes the username correctly, and again, if I put in the username & password manually, it works fine.

I've include my script below:

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery ("Select * FROM Win32_Service Where Name = 'CustomService'")

For Each objservice in colServiceList
errReturn1 = objService.change(,,,,,,"DOMAIN\UserName","PassWord")

If errReturn1 <> 0 then
msgbox("Error #" & errReturn1 & " when trying to setup Service.")
End if

If errReturn1 = 0 then
errReturn2 = objService.startservice
If errReturn2 <> 0 then
msgbox("Error #" & errReturn2 & " when trying to start the Service.")
End if
End if

Next

if errReturn1 = 0 and errReturn2 = 0 then
Msgbox("Completed setting up Services")
end if
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
[8D]

That particular user probably doesn't have the neccessary rights on the local computer to start/stop services. When you alter the details using the GUI, it will automatically give the user the required user rights to start/stop services.

To enable the user to start/stop services, you need to give that user account the 'Log on as a service' within the Local Security Policy.
Answered 02/14/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
If I recall correctly, the problem I had last year was the account that it was running as didn't have logon as service rights. (So yes, you were right). I believe that I used one of the tools in the Microsoft Resource Kit to grant the user the correct rights. If anyone needs to do this in the future, I'd be glad to go back and look to see which tool it was, but I'm sure a quick search will yeild the correct results for you.
Answered 02/14/2005 by: usachrisk
Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity