/build/static/layout/Breadcrumb_cap_w.png

VBScript - Changing Service

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

Answers (2)

Posted by: brenthunter2005 19 years ago
Fifth Degree Brown Belt
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.
Posted by: usachrisk 19 years ago
Purple Belt
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.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ