PDA

View Full Version : Changing who own an existing windows service



Marvin_The_Martian
10-24-2008, 05:03 AM
I got a service and I want to change the account it runs under from within .net but I know only how to set up a serviceinstaller to use an acount or username/password, not a way to change an installed service's parameters.

I can do it dirty through the registry but I rather avoid using that, anyone who can help me gets a cookie :toast:

nm

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service")
For Each objservice in colServiceList
If objService.StartName = ".\netsvc" Then
errReturn = objService.Change( , , , , , , , "password")
End If
Next

I think I can modify this :)

Sometimes I when you hit a wall, you have to push harder :rofl: