Setting a service to MANUAL

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
P

Paul Aspinall

Hi
I have a service installed, but I want to programatically set it to 'Manual'
startup, rather than 'Automatic'.

I cannot do this with 'System.serviceProcess.ServiceInstaller()' as I don't
actually install the service (MSDE does), but I want it set to Manual, and
my app starts and stops it.

I can Start and Stop the service, but need it to be Manual, and not
Automatic

Any help appreciated


Thanks


Paul
 
The ServiceInstaller class has a property called 'StartType' this defaults
to 'Manual'. Is this being set to 'Automatic' somewhere in your code?


--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
 
Hi,

You can use the ServiceInstaller class to set the same. For this, you need
to do the following (You could have done some of them already)
1. Reference the System.ServiceProcess.ServiceInstaller. Do this by using
"Add/Remove Item" option from right clicking on the "Components" tab in
ToolBox. Find the "ServiceInstaller". Select it.
2. Drag the ServiceInstaller and name it (lets say "testinstaller"). You
will see an entry in the "Component Designer generated code" section in your
project.
3. Now in your install event, you can say, testinstaller.StartType =
ServiceStartMode.Manual.

You can see an example here...
http://www.codeproject.com/csharp/csharpsvclesson2.asp

Hope this helps.

Ganesh
 
Hi Paul,

If you want to do it from code, after the service is installed you have to
change it in the registry , in
LOCAL_MACHINE\System\\CurrentControlSet\\Services\\ change the Start value,
2 is auto , 3 is manual.


cheers,
 
Use the System.ServiceProcess.ServiceController class. It allows
programmattic control of many service properties.
 
Back
Top