/build/static/layout/Breadcrumb_cap_w.png

service

i want to disable a service them start it under and different username and password how can i do that, i know how to stop the services but i don't know how to start it under and different user

this is what i have so far

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='iPod Service'")
For each objService in colServiceList
errReturn = objService.StopService()
Next

0 Comments   [ + ] Show comments

Answers (3)

Posted by: spartacus 18 years ago
Black Belt
0
In the following script, replace DOMAIN\USERNAME and PASSWORD with your actual values :

Option Explicit

Const ServiceToChange = "iPod Service"

Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService, intSleep
strComputer = "."
intSleep = 10000

On Error Resume Next

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service")
For Each objService in colListOfServices
if objService.Name = ServiceToChange then
' Alter credentials for service to run under
objService.Change , , , , , ,"DOMAIN\USERNAME","PASSWORD"
objService.StopService()
wscript.sleep intSleep
objService.StartService()
exit for
end if
Next

WScript.Quit



[NB: This won't work inside a Windows Installer custom action (if that's what you plan to do) because of the references to wscript.quit and wscript.sleep. If you need to acheive this in an MSI, have a look at the Windows Installer SDK documentation on the ServiceControl table and use that instead.

Regards,

Spartacus
Posted by: linstead 18 years ago
Blue Belt
0
Thanks for your reply, i want to add someone to the "log as service group" via script how can i do that

Thanks in advance
Posted by: spartacus 18 years ago
Black Belt
0
I don't believe this is possible via a script, you would need to create a compiled exe that makes use of the LsaAddAccountRights function.

An alternative would be to look at using the NTRIGHTS utility - if a scripted solution is needed, you could always shell out to NTRIGHTS (bit kludgy, I know ).

Regards,

Spartacus
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