Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top