[2005] Change Service Startup Type
I want to be able to get & change the startup type for a service through a Windows Application... (Automatic, Manual, Disabled)... Is there a simple way to do this? I didn't see anything using the ServiceController.... I found another thread to use a vbscript but rather do it directly through my application.
Re: [2005] Change Service Startup Type
You can use the ServiceController component, one second I will dig out the exact code
Re: [2005] Change Service Startup Type
Actually, my bad, you cant do it through the ServiceController. The way I have done it in the past is to use the built in program in windows named SC.EXE (ie just calling that from Process.Start with certain arguments)
However, if anyone has an all .NET way of doing it I would be interested to see it :)
Re: [2005] Change Service Startup Type
The startup type for a service is stored in the Registry, in the Start value under the "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\ServiceNameHere" key. You can use the My.Computer.Registry.GetValue and SetValue to manipulate it. The value is an integer:
2 = Automatic
3 = Manual
4 = Disabled