【问题标题】:Issue installing Windows Service安装 Windows 服务时出现问题
【发布时间】:2014-05-15 20:34:29
【问题描述】:

我正在尝试为 Windows 服务创建安装程序,但我不知道为什么会失败。

这是我定义服务相关部分的片段:

<ComponentGroup Id="ServiceComponents" Directory="InstallDirectory">
  <Component Id="ThingService" Guid="1F4D7F24-BC66-4E7A-AC33-A7E2133FC5B8" KeyPath="yes">
    <ServiceInstall Id="ThingServiceInstaller"
                    Type="ownProcess"
                    Name="ThingService"
                    DisplayName="Thing"
                    Description="Does Thing."
                    Start="auto"
                    ErrorControl="normal"
                    Vital="yes" />
    <ServiceControl Id="StartService"
                    Start="install"
                    Stop="both"
                    Remove="uninstall"
                    Name="ThingService"
                    Wait="yes" />
  </Component>
</ComponentGroup>

这是运行的最后一部分 - 文件都已提前部署,我可以看到它们到达了应有的位置。当它启动服务时,我收到以下错误:

服务“ThingService”(ThingService) 无法启动。验证您是否有足够的权限来启动系统服务。

但是,我根本没有在服务列表中看到该服务,所以我什至不知道它在尝试启动什么。我觉得我缺少某种指向 Thing.exe 的指针,但我看到的示例似乎也没有。

以下是详细日志中似乎相关的部分:

1:

MSI (s) (50:F8) [16:14:38:880]:组件:ThingService;已安装:不存在;请求:本地;行动:本地

2:

MSI (s) (50:F8) [16:14:40:736]:执行操作:StopServices

MSI (s) (50:F8) [16:14:40:736]:注意:1: 2205 2: 3: ActionText

行动 16:14:40:停止服务。停止服务

动作开始时间 16:14:40:StopServices。

StopServices:服务:停止服务

操作于 16:14:40 结束:StopServices。返回值 1。

MSI (s) (50:F8) [16:14:40:740]:执行操作:DeleteServices

MSI (s) (50:F8) [16:14:40:740]:注意:1: 2205 2: 3: ActionText

行动 16:14:40:删除服务。删除服务

动作开始时间 16:14:40:DeleteServices。

操作于 16:14:40 结束:DeleteServices。返回值 1。

MSI (s) (50:F8) [16:14:40:747]:执行操作:RemoveRegistryValues

MSI (s) (50:F8) [16:14:40:747]:注意:1: 2205 2: 3: ActionText

行动 16:14:40:删除注册表值。删除系统注册表值

动作开始时间 16:14:40:RemoveRegistryValues。

操作于 16:14:40 结束:RemoveRegistryValues。返回值 1。

3:

MSI (s) (50:F8) [16:14:40:944]:执行操作:InstallServices

MSI (s) (50:F8) [16:14:40:944]:注意:1: 2205 2: 3: ActionText

行动 16:14:40:安装服务。安装新服务

动作开始时间 16:14:40:InstallServices。

操作于 16:14:40 结束:InstallServices。返回值 1。

MSI (s) (50:F8) [16:14:40:945]:执行操作:StartServices

MSI (s) (50:F8) [16:14:40:945]:注意:1: 2205 2: 3: ActionText

行动 16:14:40:启动服务。启动服务

动作开始时间 16:14:40:StartServices。

StartServices: 服务:启动服务

操作于 16:14:40 结束:StartServices。返回值 1。

4:

MSI (s) (50:F8) [16:14:40:994]:执行操作:ActionStart(Name=StopServices,Description=Stopping services,Template=Service: [1])

行动 16:14:40:停止服务。停止服务

MSI (s) (50:F8) [16:14:40:996]:执行操作:ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)

MSI (s) (50:F8) [16:14:40:996]:执行操作:ServiceControl(,Name=ThingService,Action=2,Wait=1,)

MSI (s) (50:F8) [16:14:40:996]:执行操作:ActionStart(Name=CreateFolders,Description=Creating folder,Template=Folder: [1])

5:

MSI (s) (50:F8) [16:14:41:817]:执行操作:ActionStart(Name=StartServices,Description=Starting services,Template=Service: [1])

行动 16:14:41:启动服务。启动服务

MSI (s) (50:F8) [16:14:41:817]:执行操作:ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)

MSI (s) (50:F8) [16:14:41:817]:执行操作:ServiceControl(,Name=ThingService,Action=1,Wait=1,)

StartServices:服务:ThingService

错误 1920。服务“ThingService”(ThingService) 无法启动。验证您是否有足够的权限来启动系统服务。

EDIT1:看起来问题在于将 ServiceInstall/ServiceControl 拆分为它们自己的组件,因为如果我将它们放入与文件定义相同的组件中,它就可以工作。

【问题讨论】:

  • 我会看看为什么您在 InstallServices 操作中返回 1 而不是 0。您可能还想在 ThingServiceInstaller 上设置 Vital="yes",以便在服务安装失败时整体安装失败。
  • @ssnobody: Vital="yes" 已经在ThingServiceInstaller 上——这是最后一行。关于要研究什么的任何想法?
  • 我会在安装时删除服务的启动,所以只需安装服务,然后尝试手动启动服务以查看问题出在哪里,也许您的应用程序没有作为本地系统启动。还要检查事件查看器是否有应用程序崩溃。

标签: wix


【解决方案1】:

ServiceInstall 必须与服务可执行文件位于同一 Component 中,因为

Windows Installer 使用 Component 表的外键而不是可执行文件的路径定义 ServiceInstall 表(请参阅http://msdn.microsoft.com/en-us/library/aa371637(VS.85).aspx)。

参考here

【讨论】:

    猜你喜欢
    • 2011-06-01
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 2019-04-24
    • 2014-07-23
    • 1970-01-01
    相关资源
    最近更新 更多