I have a .Net C# Windows service app that works nicely now, and installs itself properly. I also have a small WinForms tool to provide a friendly interface to modify its config file.
It occurs to me that a nice touch would be to extend this tool to configure the service itself as well (the stuff you do in the Services admin tool, eg Startup mode, Windows login account credentials, etc).
Can this be done relatively easily with the .Net framework?
You cannot use .net directly to do this as far as I know. But you can call the Win32 Api for methods to accomplish it. An example is posted on this Blog. You can probably also find more functionality over at pinvoke
You can accomplish a lot using the
Service Controller
class. It enables Starting/Stopping etc.The rest you can do by calling the
sc
tool the same way you would using a console: