TOANDO

I have a windows service that runs on a little over 100 locations. Every time I upgrade the service and do a re-install, we have about 5% of the locations get a logon failure message. The account that the service is trying to run under is a domain account that has the credentials setup in the project installer class of the service. All I have to do to fix the problem is to manually go into the service once it is installed and re-enter the password and then start the service. When I re-enter the password, the service manager will pop-up a message stating that the account is now registered to run as a service (or something like that). Does anyone know why this may occur All of the machines that this service is running on are XP with SP2. The Service was developed in .Net 1.1. Any ideas would be greatly appreciated.

Here is the section of code that sets up the service installer:

private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Password = "password";
this.serviceProcessInstaller1.Username = "Domain\\UserName";
//
// serviceInstaller1
//
this.serviceInstaller1.DisplayName = "MyService";
this.serviceInstaller1.ServiceName = "MyService";
this.serviceInstaller1.ServicesDependedOn = new string[] {"Workstation"};
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
this.serviceInstaller1.Committed += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_Commited);
this.serviceInstaller1.BeforeUninstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_BeforeUninstall);
this.serviceInstaller1.BeforeRollback += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_BeforeRollback);
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.serviceProcessInstaller1, this.serviceInstaller1});
}



Re: ClickOnce and Setup & Deployment Projects Windows Service Installation question

PhilWilson

That account doesn't have the Log on as a service right. When you use the UI to run a service with that account it adds that right for you. Programmatically installing the service with that account does not add that right.






Re: ClickOnce and Setup & Deployment Projects Windows Service Installation question

TOANDO

Do you know of a way that I can programatically give the user account access Is there a registry setting that I can check for and update if needed





Re: ClickOnce and Setup & Deployment Projects Windows Service Installation question

PhilWilson

There are Win32 API calls for it - I'm unaware of any .NET classes.

http://msdn2.microsoft.com/en-us/library/ms721863.aspx






Re: ClickOnce and Setup & Deployment Projects Windows Service Installation question

TOANDO

Thank you PhilWilson! I was able to find the below link after your recommendations. This doesn't explain exactly what to do, but gets me close enough to figure it out from here. I'll post an update once I figure out the best way.

http://www.codeproject.com/csharp/lsadotnet.asp