0

我已经使用 Wix 开发了 Windows 服务安装程序。服务设置为安装后自动启动。安装程序有自定义对话框,它将接受用户输入并更新 .config 文件。输入是可选的。

未提供输入时,不会更新配置文件。我可以从 services.msc 重新启动 windows 服务。如果用户提供输入,自定义操作(延迟)将更新配置文件。此自定义操作以 Impersonate="no" 模式运行。

在这种情况下,Windows 服务会在安装后自动启动,一切正常。但是当我重新启动服务时,它会抛出以下错误。

在此处输入图像描述

下面是安装服务的代码:

 <Component Id="CMPFa85281c3_a329_4a93_a1d7_203fbccec31f" Guid="*" Directory="INSTALLLOCATION">
  <Condition>
    <![CDATA[Installed OR (SVCINSTALL <> 0)]]>
  </Condition>
  <RemoveFile Id="RmFa85281c3_a329_4a93_a1d7_203fbccec31f" Name="MyService.exe" On="both" />
  <File Id="Fa85281c3_a329_4a93_a1d7_203fbccec31f" Source="$(var.BaseDir)\MyService.exe" KeyPath="yes" />

  <ServiceInstall Id="InstallWindowsService" Name="MyService"
                  DisplayName="MyService"
                  Start="auto"
                  ErrorControl="normal"
                  Type="ownProcess"
                  Account="[USER_DOMAIN]\[SERVICEUSER]"
                  Password="[PASSWORD]"
                  Description="MyService"/>

  <ServiceControl Id="sc_InstallWindowsService" Name="MyService" 
                  Start="install" Remove="uninstall" Stop="both" Wait="no"/>
</Component>

下面是自定义操作的代码。

<CustomAction Id="UpdateConfigFiles"
              Return="check"
              Execute="deferred"
              Impersonate="no"
              BinaryKey="MyCustomAction.dll"
              DllEntry="UpdateFilePath"
              HideTarget="yes">
</CustomAction>

<InstallExecuteSequence>
  <Custom Action="PassData" Before="UpdateConfigFiles">NOT Installed AND NOT PATCH AND NOT REMOVE</Custom>
  <Custom Action="UpdateConfigFiles" Before="InstallFinalize">NOT Installed AND NOT PATCH AND NOT REMOVE</Custom>
</InstallExecuteSequence>
4

1 回答 1

0

从这样的事情来看:

https://support.microsoft.com/en-us/kb/2478117

该错误可能与启动服务的权限不足有关。自定义操作或配置步骤没有理由产生影响,除非它当然会导致服务以新帐户启动或导致它在同一进程中共享两个服务,这就是消息所说的。似乎这与安装无关,因为没有产生这种效果的机制。

重现的场景我仍然不清楚,但似乎安装可以启动服务(并且安装使用本地系统帐户运行)所以它成功,但是根据知识库文章的错误消息意味着用户试图启动它没有足够的权限,否则错误表明该进程正在尝试使用两个帐户,可能一个在配置文件中,另一个是安装配置的。

于 2016-12-17T21:23:41.953 回答