如何在C#中将服务安装为当前帐户 [英] How to Install a service as the current account in c#

查看:253
本文介绍了如何在C#中将服务安装为当前帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我当前使用的安装程序代码中:

In my installer code I'm currently using:

 processInstaller.Account = ServiceAccount.LocalSystem;

但是我们的一位客户已配置了代理,因此该服务帐户无法访问Internet.当前,我们必须在安装后手动配置所有服务,但是如果我们可以让它们自动使用安装用户的凭据,则不必这样做.有谁知道这可以做到吗?

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?

谢谢, 理查德

推荐答案

您可以将帐户"类型设置为user,然后指定用户名和密码.

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";

这篇关于如何在C#中将服务安装为当前帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆