/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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   [ - ] Hide 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.
Answer this question or Comment on this question for clarity

Answers

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
Answered 10/13/2006 by: spartacus
Black Belt

Please log in to comment
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
Answered 10/13/2006 by: linstead
Blue Belt

Please log in to comment
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
Answered 10/16/2006 by: spartacus
Black Belt

Please log in to comment