Installing Windows Service - No mapping between account names and security ID's were done

Viewed 31577

I have a windows service and setup project. When I right click on the setup project and click install it prompt me for

  • Username
  • Password
  • Confirm Password

I have tried the following combinations

.\MyUserName MyDomain\MyUserName

but it comes back with the following error

No mapping between account names and security ID's were done

ServiceProcessInstaller

namespace TestService
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {

        public ProjectInstaller()
        {
            InitializeComponent();

            this.serviceProcessInstaller1.Account = ServiceAccount.User;
            this.serviceProcessInstaller1.Username = @".\MyUserName"; //username;
            this.serviceProcessInstaller1.Password = "123456"; // password;

            // Add installers to collection. Order is not important.
        }

        private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
        {

        }

        private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
        {

        }
    }
}

To be honest, I'm not even sure why I am prompted for a username and password if I set it in the code...

5 Answers

Just add the configuration code below in InitializeComponent method installer.

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
Related