在自定义操作中复制批处理文件的行为

问题描述 投票:0回答:1

我正在工作中创建一个wix安装程序,我需要能够在自定义操作中复制此批处理文件的行为:

start /d "C:\Program Files (x86)\Remindex" INSTSRV.EXE RemindexNP 
"C:\Program Files (x86)\Remindex\SRVANY.EXE"

我正在尝试使用普通的 Windows 应用程序创建服务,SRVANY.EXE 可以做到。该批处理文件正常运行,但我似乎无法获得自定义操作来执行相同的操作。我试过这个:

<CustomAction Id="RunNP" FileKey="FILE_INSTALLFOLDER_INSTSRVEXE" 
              ExeCommand="RemindexNP [INSTALLFOLDER]SRVANY.EXE" Execute="commit" Return="ignore"/>

此自定义操作不会导致我在日志文件中看到的任何错误,但我认为 instsrv.exe 不接受我在 ExeCommand 中传递的参数。我知道 instsrv.exe 和 srvany.exe 存在,因为我在 InstallFinalize 之前运行自定义操作。

有人知道我的自定义操作有什么问题吗?

我不想在我的安装文件夹中包含实际的批处理文件,因为除了在安装时运行之外,它没有理由在那里。我尝试在安装程序中包含一个,但我不知道如何引用安装目录。当我使用 %cd% 时,由于某种原因它只是引用系统文件夹。

我尝试使用 ServiceInstall 和 ServiceControl 元素,但安装程序卡在“启动服务”上。这是我的组件:

<Component Id="CMP_RemindexNP.exe" Guid="{3FB99890-752D-4652-9412-72230695A520}">
    <File Id="FILE_INSTALLFOLDER_RemindexNPEXE" Source="RemindexNP.exe" KeyPath="yes"/>
        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\RemindexNP\Parameters">
          <RegistryValue Id="rg_remNP1" Action="write" Name="AppDirectory" Value="[INSTALLFOLDER]" Type="string"/>
          <RegistryValue Id="rg_remNP2" Action="write" Name="Application" Value="[INSTALLFOLDER]RemindexNP.exe" Type="string"/>
        </RegistryKey>
        <ServiceInstall DisplayName="RemindexNP" Id="srv_remNP" Name="RemindexNP" Start="auto" Type="shareProcess" ErrorControl="ignore"/>
        <ServiceControl Id="srvc_remNP" Name="RemindexNP" Remove="both" Start="install" Stop="uninstall" Wait="no"/>
      </Component>

还有我的日志:

Action 17:15:08: StartServices. Starting services
Action start 17:15:08: StartServices.
StartServices: Service: Starting services
Action ended 17:15:08: StartServices. Return value 1.
batch-file wix windows-installer custom-action wix3.7
1个回答
2
投票

这是一个棘手的问题,因为您不需要自定义操作。 srvany.exe 充当服务主机,因此可以使用目录、组件、文件、ServiceInstall 和(如果需要)ServiceControl 元素将其编写到安装程序中。

© www.soinside.com 2019 - 2024. All rights reserved.