[英]How to Install a service as the current account in c#
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谢谢,理查德
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";
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 http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceaccount.aspx提示用户输入他希望安装的用户帐户和密码,并将这些凭据设置为帐户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.