Windows Service Choose User or System Account on Install

Yes there is, it's on the process installer. I think in the newer frameworks it's a visible property if you select the process installer on the design surface. The last time I did it (.NET 2.0) you have to add something similar to this to the *.designer.cs file:

 processInstaller.Account = ServiceAccount.LocalService;
 processInstaller.Username = null;
 processInstaller.Password = null;

Adding to previous answers, don't forget to append Machine name to Username while entering "Username" Field of password prompt. Otherwise service will not accept the credentials although if you give correct username and pwd. It will keep on pop up prompt to enter credentials. It took me one day to figure out this. Thanks to Badgerspot!


@Doobi, @Eric, in my experience (Win7Home 64-bit, VS2010Express, not on a domain)

 processInstaller.Account = ServiceAccount.LocalService;
 processInstaller.Username = null;
 processInstaller.Password = null;

will install the service as LocalService without a password prompt.

To install the service as a local user account (and provide a password prompt to enable the user to supply the credentials) I had to use:

 this.serviceProcessInstaller.Account =System.ServiceProcess.ServiceAccount.User;
 this.serviceProcessInstaller.Password = null;
 this.serviceProcessInstaller.Username = null;

The important step I had to take to get the service installed is to put the computer name in the credentials dialog box, ie MYPC\dave instead of dave. I was surprised that I'd have to do this as it's not on a domain. I've added this comment as no other posts I've seen about this mention having to prefix the username with the PC name.