When installing a windows service, is there a way to let the user installing choose between a specific user account and a computer account, such as LocalSystem? I see how to do this at build time through service installer properties, but not during install.
A service should only run under the LocalSystem account if the service requires administrative privileges or must act as part of the operating system on the local computer. Be aware that the service installer should, by default, set up the service to run under a domain user account.
Open the Administrative Tools > Services window on your Windows server. Stop the JetBrains YouTrack service. Open the Properties > Log On dialog. Change the service user account to the target user account.
In case you need the same service running on the same host but with different configuration, logically you would use same code just copy the service folder with different configuration and use installutil to install service with a different name.
@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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With