How to install a windows service programmatically in C#?
I have 3 projects in my VS solution. One of them is a Web app, the second one is a Windows Service and the last one a Setup project for my Web app. What I want is by the end of the installation of the web app in my setup project, within my custom action to try and install my windows service given that I have the location of the assembly by then. I found several errors in the code that you reused and have fixed these and also cleaned it up a little. Again, the original code is taken from here . public static class ServiceInstaller { private const int STANDARD_RIGHTS_REQUIRED = 0xF0000; private