开发者

Install Windows service to run under user's credentials with ServiceAccount.User but don't prompt

I have created a C# Windows Service and its accompanying Visual Studio Setup project that creates an installer. It successfully installs the service.

When I choose any value from enum ServiceAccount apart from ServiceAccount.User, the service installs without prompting using the appropriate built-in user. What I am after is actually installing the service under current user's credentials. When I specify ServiceAccount.User, I get a prompt for a user name and password during installation. What I need to do is find a way to install the service with the credentials of the user who is running the setup without prompting for password.

Is this开发者_StackOverflow社区 at all possible? I am willing to resort to any measures needed (like loads of P/Invoke) to get the job done.


You can't, there's no way to extract the clear-text password unless something is misconfigured and you'll need that to set up the service. See this similar question.

Also, in general, services should be installed with a separate and unique account per service with least privilege.


This won't be possible as suggested by others. Even when from service manager you want to run the service under some other account (even if it current user account) it asks you to type the password again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜