Windows服务在安装时选择用户或系统帐户 [英] Windows Service Choose User or System Account on Install
问题描述
在安装Windows服务时,是否可以让安装的用户在特定用户帐户和计算机帐户(例如LocalSystem)之间进行选择?我在构建时会通过服务安装程序属性来了解如何执行此操作,而在安装过程中则不会.
When installing a windows service, is there a way to let the user installing choose between a specific user account and a computer account, such as LocalSystem? I see how to do this at build time through service installer properties, but not during install.
推荐答案
@Doobi,@Eric,根据我的经验(Win7Home 64位,VS2010Express,不在域上)
@Doobi, @Eric, in my experience (Win7Home 64-bit, VS2010Express, not on a domain)
processInstaller.Account = ServiceAccount.LocalService;
processInstaller.Username = null;
processInstaller.Password = null;
将在没有密码提示的情况下将服务安装为LocalService.
will install the service as LocalService without a password prompt.
要将服务安装为本地用户帐户(并提供密码提示以使用户能够提供凭据),我必须使用:
To install the service as a local user account (and provide a password prompt to enable the user to supply the credentials) I had to use:
this.serviceProcessInstaller.Account =System.ServiceProcess.ServiceAccount.User;
this.serviceProcessInstaller.Password = null;
this.serviceProcessInstaller.Username = null;
要安装该服务,我必须采取的重要步骤是将计算机名称放在凭据对话框中,即 MYPC \ dave
而不是 dave
.我很惊讶我必须这样做,因为它不在域中.我已添加此评论,因为我没有看到其他关于此提及的帖子,而必须在用户名前面加上PC名称.
The important step I had to take to get the service installed is to put the computer name in the credentials dialog box, ie MYPC\dave
instead of dave
. I was surprised that I'd have to do this as it's not on a domain. I've added this comment as no other posts I've seen about this mention having to prefix the username with the PC name.
这篇关于Windows服务在安装时选择用户或系统帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!