加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

Windows服务 – 无法在WiX安装程序中安装和启动Windows服务

发布时间:2021-03-14 07:27:38 所属栏目:Windows 来源:网络整理
导读:我正在使用WiX v3.8创建一个安装和启动 Windows服务的MSI软件包.代码如下: Component Id="INSTALLAPSSERVICE" Guid="991D5F82-0E77-4FE3-B1D8-4C941B84C7CD" Win64="yes" File Id="ApsService.exe" Name="ApsService.exe" Source="ResourceApsService.ex

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

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

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

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在安装期间无法启动服务时发送的通用消息.几乎总是出现这样的问题:服务在发生启动时缺少依赖关系或者没有完全配置.要调试根问题尝试:

>安装MSI包.
>当错误对话框出现时,表示启动服务无法启动*请勿关闭对话框.
>启动services.msc或从命令行使用sc.exe尝试启动您的服务. Windows Installer应该已经配置足够的服务,以便能够更深入地调试它为什么失败.
>如果有必要,可以直接调试到您的服务执行程序,看看为什么不能启动.

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

祝你好运调试你的服务!

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读