Search This Blog

Tuesday, May 17, 2011

Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with ...

In order to run a Windows Service, do the following:

1) Build your Windows Service Project in VS.NET to generate its exe.

2) Run the Visual Studio.NET 2003 Command Prompt; OR On the DOS prompt, go to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 (Directory path may vary).

3) Use the following command to run your Windows Service. (Subsitute the items in [...] according to your local app.)

installutil C:\[YourAppPath]\[AppName]\[Debug Release]\[AppName].exe

system.componentmodel.win32exception: no mapping between account names and security ids was done

When installing a windows service using installutil, it prompts for username & password, and after providing the username and the password it gives the following error:

system.componentmodel.win32exception: no mapping between account names and security ids was done

To resolve this problem add the below line to the ProjectInstaller.cs file (in InitializeComponent)
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;