当帐户不是 LocalSystem 时,WiX Windows 服务不会启动 [英] WiX Windows Service won't start when Account is not LocalSystem

查看:21
本文介绍了当帐户不是 LocalSystem 时,WiX Windows 服务不会启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将安装应用程序转换为 WiX,我遇到了用 C# 编写的 Windows Service 应用程序的以下现象:

Converting setup applications to WiX, I am encountering the following phenomenon for a Windows Service application written in C#:

1.) 配置具有 ServiceInstall 部分的主要 EXE 组件分配帐户 =LocalSystem".应用程序将成功安装但不会运行(-start).它没有对将要连接的数据库进行身份验证,因此不足为奇.

1.) Configuring the main EXE component having the ServiceInstall section assign Account="LocalSystem" the application will install successfully but will not run (-start). It does not have authentication to the database to which it will connect so not too surprising.

2.) 使用第一项中的安装,我将 ValidAccount 和 ValidPassword 应用到Log On"服务的属性选项卡.像预期的那样手动完成后,服务启动并成功运行.

2.) Using the installation from item one, I apply the ValidAccount and ValidPassword to the "Log On" tab of properties for the service. The service starts and runs successfully when done manually like this as is expected.

3.) 回到 Wix 项目,我将上述 ServiceInstall 部分更改为具有相同的 Account=ValidAccount";密码=有效密码"在步骤 2 中使用并重建 MSI 文件.在 ServiceInstall 之后,安装无法安装并显示以下日志消息:

3.) Going back to the Wix project, I change the afforementioned ServiceInstall section to have the same Account="ValidAccount" Password="ValidPassword" used in step 2 and rebuild the MSI file. The installation fails to install with the following log messages just after the ServiceInstall:

InstallServices: Service: 
    Error 1923. Service 'My Service' (MyService.exe) could not be installed. Verify that you have sufficient privileges to install system services.
    MSI (s) (B4:30) [12:54:38:616]: I/O on thread 20432 could not be cancelled. Error: 1168
    MSI (s) (B4:30) [12:54:38:616]: I/O on thread 13032 could not be cancelled. Error: 1168
    MSI (s) (B4:30) [12:54:38:616]: I/O on thread 10548 could not be cancelled. Error: 1168
    MSI (s) (B4:30) [12:54:38:616]: I/O on thread 19688 could not be cancelled. Error: 1168
    MSI (s) (B4:30) [12:54:38:616]: I/O on thread 6588 could not be cancelled. Error: 1168
    MSI (s) (B4:30) [12:54:38:616]: I/O on thread 10132 could not be cancelled. Error: 1168
    MSI (s) (B4:94) [12:54:38:616]: Product: MyService -- Error 1923. Service 'My Service' (MyService.exe) could not be installed. Verify that you have sufficient privileges to install system services.

4.) 我已确认 ValidAccount 是本地管理员组的成员.

4.) I have confirmed that the ValidAccount is a member of the Local Administrators group.

5.) 我已确认 ValidAccount 已添加到作为服务登录"中.政策.

5.) I have confirmed that the ValidAccount is added to the "Log on as a service" policies.

6.) 我在服务中没有 GAC 依赖项(有人指出 GAC 依赖项是在最后添加的,可能会中断安装.)

6.) I have no GAC dependencies in the service (someone sited that GAC dependencies are added at the very end and could disrupt the installation.)

我错过了什么?...即使是使用 LocalSystem 的什么都不做的服务也很好.但是,如果我如下设置帐户和密码,它将无法安装.

What am I missing? ... even a do nothing service using LocalSystem is fine. However, it won't install if I set the Account and Password as in the below.

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="TestService.exe" Guid="196BB5E5-F157-4CA2-B740-0A68E1539B7C">
        <File 
          Id="TestService.exe" 
          Source="$(var.TestService.TargetPath)" 
          KeyPath="yes" />
    
        <ServiceInstall 
          Id="TestService.exe" 
          Name="TestService.exe" 
          DisplayName="Test Service"
          Description="This is a test service to test installation with WiX."
          Account="myDomain\myAccount" <!-- using myAccount without the domain yields same failure -->
          Password="myAccountPassword"
          Arguments="-start" 
          Start="auto" 
          Interactive="yes" 
          Type="ownProcess" 
          Vital="yes" 
          ErrorControl="ignore" />

        <ServiceControl 
          Id="TestService.exe" 
          Name="TestService.exe" 
          Stop="both" 
          Start="install" 
          Remove="uninstall" 
          Wait="no" />
      </Component>
    </ComponentGroup>
  </Fragment>

提前致谢,

肯特

推荐答案

经过一系列的实验,我想出了答案.它实际上似乎是 WiX 工具集(版本 3.11.2)中的一个错误,但我不确定是否有人故意这样做.当您向 ServiceInstall 添加密码时,必须将 Interactive 属性设置为no".

After a bunch of experimentation, I came up with the answer. It actually appears to be a bug in the WiX Toolset, (version 3.11.2,) but I am not sure if someone did this by design. When you add a Password to the ServiceInstall, the Interactive property MUST be set to "no".

由于某些未知原因,如果您将其设置为是"只安装不需要密码的帐户.

For some unknown reason, if you set it to "yes" only Accounts that do not require passwords will install.

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="TestService.exe" Guid="196BB5E5-F157-4CA2-B740-0A68E1539B7C">
        <File 
          Id="TestService.exe" 
          Source="$(var.TestService.TargetPath)" 
          KeyPath="yes" />
    
        <ServiceInstall 
          Id="TestService.exe" 
          Name="TestService.exe" 
          DisplayName="Test Service"
          Description="This is a test service to test installation with WiX."
          Account="myDomain\myAccount" <!-- using myAccount without the domain yields same failure -->
          Password="myAccountPassword"
          Arguments="-start" 
          Start="auto" 
          Interactive="no" <!-- MUST BE NO WHEN PASSWORD IS USED -->
          Type="ownProcess" 
          Vital="yes" 
          ErrorControl="ignore" />

        <ServiceControl 
          Id="TestService.exe" 
          Name="TestService.exe" 
          Stop="both" 
          Start="install" 
          Remove="uninstall" 
          Wait="no" />
      </Component>
    </ComponentGroup>
  </Fragment>

祝你一切顺利,肯特

这篇关于当帐户不是 LocalSystem 时,WiX Windows 服务不会启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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