Reputation: 95
when I try to install the service (installutil service.exe) from Visual Studio command Prompt, it prompts to set User ID, Password to install the service. You can refer to the screenshot(link) of credential prompt.
picture of prompting for credentials while installing service.
This was done in C#.net with .NET 4.0 framework.
I have searched for this prior posting this question and end-up setting the credentials to null (please refer to the code pasted below). But it didn't work.
private void InitializeComponent()
{
this.StockManagementProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.StockManagementInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// StockManagementProcessInstaller1
//
this.StockManagementProcessInstaller1.Password = null;
this.StockManagementProcessInstaller1.Username = null;
//
// StockManagementInstaller1
//
this.StockManagementInstaller1.DisplayName = "StockManagement";
this.StockManagementInstaller1.ServiceName = "StockManagement";
this.StockManagementInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.StockManagementProcessInstaller1,
this.StockManagementInstaller1});
}
Can anyone help me how to get rid of this and install the service without any problem?
Upvotes: 2
Views: 1453
Reputation: 3139
Install your service as local service without a password prompt , just do the following:
// StockManagementProcessInstaller1
//
this.StockManagementProcessInstaller1.Account = ServiceAccount.LocalService;
this.StockManagementProcessInstaller1.Password = null;
this.StockManagementProcessInstaller1.Username = null;
Instead of:
// StockManagementProcessInstaller1
//
this.StockManagementProcessInstaller1.Password = null;
this.StockManagementProcessInstaller1.Username = null;
I hope that support your question.
Upvotes: 2