简体   繁体   English

如何在 c# 中将服务安装为当前帐户

[英]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.

相关问题 如何使用 c# 以编程方式安装系统服务以使用组托管服务帐户 (gMSA)? - How can I programmatically install a system service using c# to use a Group Managed Service Account (gMSA)? 如何在C#应用程序中保护服务帐户? - How to secure service account in c# app? 如何将新服务帐户引入现有C#Windows服务 - How to introduce a new service account to an existing C# windows service 如何在 C# 中以编程方式安装 Windows 服务? - How to install a windows service programmatically in C#? 如何在 C# 中使用服务帐户登录 Google API - 凭据无效 - How to login to Google API with Service Account in C# - Invalid Credentials 如何通过服务帐户和集成安全性运行WPF(C#)应用程序 - How to run wpf(c#) application by service account and integrated security 如何获得SQL Server服务与C#一样运行的帐户? - How to get the account the SQL Server service runs as with C#? 如何通过服务帐户在 c# 上使用 Admob API? - How to use Admob API on c# via Service Account? 如何在本地系统帐户下禁止C#服务启动? - How to forbid C# service from start under LocalSystem account? C#如何禁用本地用户帐户的交互式登录。 与网络服务帐户类似 - C# How do I disable interactive login for a local user account. Similar to Network Service account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM