Posts

Showing posts from February, 2011

windows-service-setup-project-run-service-as-administrator

You should be able to add a new ServiceProcessInstaller in the InitializeComponent() method of your installer. This class will allow you to set account type, username, and password that you want the service to run as. For example: this.Installers.Add( new System.ServiceProcess.ServiceProcessInstaller() { Account = ServiceAccount.User, Username = @"domain\username", Password = "password" }); If you don't want to hardcode a password into your setup project, then leave it blank and a popup dialog should appear asking for this during install. http://stackoverflow.com/questions/1692679/windows-service-setup-project-run-service-as-administrator

How to Install Windows Service

Creating the solution To create the solution, use "File." "New." and select "Blank Solution. from the Visual Studio development environment. For this example, call the solution "ServiceSolution". All related projects (especially those that will be part of a installation, should become a project within the root solution. This keeps all inter-project dependencies relative to one another an simplifies the process if another developer decides to use a working folder. The next step is to create two new projects as part of this solution the service application and the installation package. Right click on the solution within the Solution Explorer and select "Add." and the "New Project." from the Visual C# projects folder, choose "Window Service". Name the project "TestService". The resulting project should now be in design mode and ready to add the installation components. The C# source file "Service1" and th...