How to Install a service as the current account in c#

吃可爱长大的小学妹 提交于 2019-12-12 12:42:46

问题


In my installer code I'm currently using:

 processInstaller.Account = ServiceAccount.LocalSystem;

But one of our clients has a proxy configured so the service account can't access the internet. Currently we have to configure all the services manually after install but if we could have them automatically use the credentials of the installing user we wouldn't have to do this. Does anyone know if this can be done?

Thanks, Richard


回答1:


You can set the Account type to user and then specify a username and password.

processInstaller.Account = ServiceAccount.User;
processInstaller.User = "domain\username";
processInstaller.Password = "Password";



回答2:


http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceaccount.aspx Prompt user to enter user account and password he wish to install with, and set those credential to account



来源:https://stackoverflow.com/questions/6586714/how-to-install-a-service-as-the-current-account-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!