简体   繁体   中英

Install/Uninstall C Windows Service

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.

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

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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM