0

I have a Windows Service that I created with .NET 4.5. It needs to run under the context of a Domain User Account (service account) to connect to a SQL Server using a trusted connection. In VS2013 I set the ProjectInstaller to use Account type "User."

When I install and start the Service for the first time it prompts be for a the username and password. This is expected since I haven't stored anywhere What I find annoying is that anytime the service is stopped and started, it continues will always ask for the username and password.

I assume (haven't been able to verify) that if service stops and is set to automatically restart, that it wouldn't be able to automatically restart because it will need the username and password.

Is there solution to this issue, possibly adding the username and password into the installer?

Josh
  • 8,219
  • 13
  • 76
  • 123

2 Answers2

0

It just doesn't sound like a great thing to embed domain account credentials into the service installer.

The following properties should help you

  • Account: The user account context in which the service runs
  • AccountType: When set to Automatic, when the machine reboots, your service will be started as part of the boot

If the service has already been installed, you can navigate to Local Services from the control panel, right click on your service from the list, and go to properties. The "logon" tab allows you to specify which account the service runs as.

Additional References:

Jason W
  • 13,026
  • 3
  • 31
  • 62
  • Agreed, ideally a switch would exist for the system to remember the name entered instead of resetting each time it is stopped. – Josh Oct 29 '14 at 00:18
0

I ended finding what I need. You can pass a username and password in the command line for installutil. Details at: Using InstallUtil and silently setting a windows service logon username/password

Community
  • 1
  • 1
Josh
  • 8,219
  • 13
  • 76
  • 123