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

查看:104
本文介绍了无法在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="Resource\ApsService.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 Installer应该已经配置了足够的服务,以便能够更深入地调试失败的原因.
  4. 如有必要,直接调试您的服务可执行文件以查看为什么无法启动它.
  1. Install the MSI package.
  2. When the error dialog comes up indicating there is a failure to start the service *do not dismiss the dialog.
  3. Start services.msc or use sc.exe from the command-line to attempt to start your service. The Windows Installer should have configured enough of the service to be able to debug deeper why it failed.
  4. If necessary debug into your service executable directly to see why it cannot be started.

如果这是用托管代码编写的服务,请确保它不依赖于放置在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天全站免登陆