I've got a setup project for a Windows Service (.net 3.5, visual studio 2008).
The Windows Service needs to be run under the Administrator account, does anyone know how I can get the Setup Project to set the "user to log on as" setting for the windows service as part of the setup process?
At the moment I have to manually right click on the service and set it to log on as the administrator everytime I update the service.
Thanks!
Create Setup Project for Window Service Open a dialog box, go to left pane under Installed Templates > Other Project Types > Setup and Deployment > Visual Studio Installer and go to the right pane and select the project as a “Setup Project” and click on the OK button.
In Solution Explorer, access Design view for the service for which you want to add an installation component. Click the background of the designer to select the service itself, rather than any of its contents. With the designer in focus, right-click, and then click Add Installer.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With