Install a Windows service to run under user credentials using ServiceAccount.User, but do not prompt

I created the Windows C # service and its accompanying Visual Studio installation project, which the installer creates. It successfully installs the service.

When I select any value from the ServiceAccount enumeration except ServiceAccount.User , the service is installed without a request using the appropriate built-in user. What I find actually installs the service under the current user credentials . When I specify ServiceAccount.User , I get a prompt for the username and password during installation. I need to find a way to install the service with the credentials of a user that runs the setup without asking for a password.

Is it possible? I am ready to resort to any necessary measures (for example, P / Invoke loads) to get the job done.

+4
source share
2 answers

You cannot, there is no way to extract a text password if something is not configured correctly and you need to configure the service. See this similar question .

In addition, in general, services should be installed with a separate and unique account for each service with minimal privileges.

+5
source

It will be impossible, as others have suggested. Even if you want to start the service under a different account from the service manager (even if it is the current user account), it will ask you to enter the password again.

+1
source

All Articles