在 WiX 安装程序中安装和启动 Windows 服务失败 [英] Failed to install and start Windows services in WiX installer

查看:24
本文介绍了在 WiX 安装程序中安装和启动 Windows 服务失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 MSI 包,用于使用 WiX v3.8 安装和启动 Windows 服务.代码如下:

I am creating an MSI package for installing and starting Windows services using WiX v3.8. The code as follows:

<Component Id="INSTALLAPSSERVICE" Guid="991D5F82-0E77-4FE3-B1D8-4C941B84C7CD" Win64="yes">
   <File Id="ApsService.exe"
         Name="ApsService.exe"
         Source="ResourceApsService.exe"
         KeyPath="yes"
         Vital="yes"
         DiskId="1"></File>
   <ServiceInstall Id="ApsServiceInstaller"
                   Name="ApsService"
                   DisplayName="ApsService"
                   Type="ownProcess"
                   Start="auto"
                   ErrorControl="normal"
                   Description="A monitor service for windows application."
                   Account="[SERVICEACCOUNT]"
                   Password="[SERVICEPASSWORD]"
                   Vital="yes"
                   Interactive="no"></ServiceInstall>
    <ServiceControl Id="StartService"
                    Start="install"
                    Stop="both"
                    Remove="uninstall"
                    Name="ApsService"
                    Wait="yes"/>
</Component>

但安装失败,日志中出现以下错误:

But install fails with the following errors in the log:

Executing op: ServiceControl(,Name=ApsService,Action=1,Wait=1,)
StartServices: Service: ApsService
Error 1920. Service 'ApsService' (ApsService) failed to start. Verify that you have      sufficient privileges to start system services.
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 3676 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 1888 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 1764 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 3504 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 2100 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 2752 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 3672 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 3876 could not be cancelled. Error: 1168
MSI (s) (F0:D0) [15:57:28:630]: I/O on thread 1400 could not be cancelled. Error: 1168
MSI (s) (F0:C0) [15:57:28:630]: Product: WinApsSetup64 -- Error 1920. Service 'ApsService' (ApsService) failed to start. Verify that you have sufficient privileges to start system services.

如何修复错误?

推荐答案

您收到的错误消息是 Windows Installer 在安装期间无法启动服务时发送的一般消息.几乎总是问题是服务缺少依赖项或在启动时未完全配置.要调试根本问题,请尝试:

The error message you are getting is the generic message the Windows Installer sends when it fails to start a service during install. Almost always the issue is that the Service is missing a dependency or otherwise not fully configured when the start occurs. To debug the root issue try:

  1. 安装 MSI 包.
  2. 当错误对话框出现时,表明服务启动失败*不要关闭对话框.
  3. 启动 services.msc 或从命令行使用 sc.exe 来尝试启动您的服务.Windows 安装程序应该已经配置了足够多的服务,以便能够更深入地调试失败的原因.
  4. 如有必要,直接调试到您的服务可执行文件以查看它无法启动的原因.

如果这是用托管代码编写的服务,请确保它依赖于放置在 GAC 中的文件.直到安装过程中的非常非常晚的时候,文件才会出现在 GAC 中.如果您必须在 GAC 中使用文件,您将无法使用内置的 ServiceControl 元素,并且必须编写自定义操作以在 InstallFinalize 之后运行.请注意,在 InstallFinalize 之后,将不会提升自定义操作,因此您的服务必须支持由非提升用户启动.同样,我建议不要依赖 GAC.

If this is a service written in managed code, ensure that it does not depend on files being placed in the GAC. Files are not in the GAC until very, very late during the installation process. If you must use files in the GAC, you will not be able to use the built-in ServiceControl element and will have to write a custom action to run after InstallFinalize. Note that after InstallFinalize a custom action will not be elevated so your service will have to support being started by non-elevated users. Again, I recommend not depending on the GAC.

祝你调试服务好运!

这篇关于在 WiX 安装程序中安装和启动 Windows 服务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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