0
votes

I have written a windows service in C. I would like to install/uninstall it without using .NET framework (installutil) or a visual studio installer (because I'm writing this in C).

I am using NSIS to install my application which contains this service among many other things. Can NSIS install/uninstall windows services, if not, how can I programatically install/uninstall a windows service in C. I have seen examples of this for C# and VB but not for C.

3
What exactly do you mean by install in C? Do you want to write the installer code yourself? Else i'd recommend learning about wix. Finding out if NSIS supports service installation is a matter of reading their docs.RedX

3 Answers

2
votes

The NSIS documentation lists the various possibilities. You simply need to pick the one most suitable to your needs.

It's much easier to get NSIS to do this than to script it yourself by calling the service control manager API.

1
votes

Yes you can create service using NSIS. Take a look at these examples

1
votes

There is no built in method in NSIS to install a windows service but you can simply us sc.exe with the "create" parameter to install it.

The details on the sc.exe command can be found here: http://support.microsoft.com/kb/251192

and you would simply call it from NSIS with a command like this

Exec '"sc.exe" create ServiceName otherparameters'