0

我有一个用于 Windows 服务的 wix 安装程序。根据要求,如果域名、用户名和密码都给出了,那么服务应该使用该用户帐户安装,否则服务应该在安装后在本地系统上运行。

如何根据条件设置帐户?下面是服务安装的代码:

<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="$(var.SvcName)" 
                  DisplayName="$(var.SvcDisplayName)"
                  Start="auto" 
                  ErrorControl="normal" 
                  Type="ownProcess"
                  Account="LocalSystem"
                  Description="$(var.SvcDescription)"/>

  <ServiceControl Id="sc_InstallWindowsService" Name="$(var.SvcName)" Start="install" Remove="uninstall" Stop="both" Wait="no"/>

</Component>
4

1 回答 1

1

我将添加两个相同的组件,除了ServiceInstall元素和条件组件,因此只安装一个。喜欢:

<Condition>DOMAINNAME And USERNAME And PASSWORD</Condition>

相反:

<Condition>Not(DOMAINNAME And USERNAME And PASSWORD)</Condition>
于 2016-12-11T00:09:14.663 回答