How do I set Service Config?

K

Ken Varn

Is there a class or method that can be called to set the configuration
settings of an existing Windows Service? In particular I want to set the
startup mode (i.e, Manual, AutoStart, etc..). I can do it with a pinvoke,
but I wanted to check first to see if there was a way to do it natively. I
noticed there is a ServiceController class, but in only allows checking of
the status, and not setting it.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
D

Derrick Coetzee [MSFT]

Ken said:
Is there a class or method that can be called to set the configuration
settings of an existing Windows Service? In particular I want to set
the startup mode (i.e, Manual, AutoStart, etc..). I can do it with a
pinvoke, but I wanted to check first to see if there was a way to do
it natively. I noticed there is a ServiceController class, but in
only allows checking of the status, and not setting it.

No, I don't believe there's any way to do this. You can alter some settings
using ServiceInstaller by uninstalling and reinstalling the service, but to
do this the service has to be stopped and you need sufficient rights to
install services (plus ServiceInstaller isn't intended to be invoked
directly). From within the service you can alter some things through
protected members of the ServiceBase class, but not any of the configuration
properties. I hope you'll consider wrapping your P/Invoke calls in a little
class library for reuse by others.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top