Replicate Behavior of a Batch File in a Custom Action

438 Views Asked by At

I'm creating a wix installer at work, and I need to be able to replicate the behavior of this batch file in a custom action:

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

I am trying to create a service using a normal windows application, which SRVANY.EXE can do. This batch file runs fine normally, but I can't seem to get a custom action to do the same thing. I have tried this:

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

This custom action doesn't cause any errors that I can see in the log file, but I don't think instsrv.exe is accepting the parameters I'm passing in ExeCommand. I know that instsrv.exe and srvany.exe exist because I'm running the custom action before InstallFinalize.

Anyone know what's wrong with my custom action?

I would prefer not to include an actual batch file in my install folder, as it would have no reason to be there besides being run on install. I have tried including one in the installer, but I don't know how to reference the install directory. When I use %cd%, it just references the system folder for some reason.

I tried using ServiceInstall and ServiceControl elements, but the installer gets stuck on "starting services". Here is my component:

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

And my log:

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

There are 1 best solutions below

2
On

This is a trick question as you don't need a custom action. The srvany.exe acts as a service host and as such can be authored into your installer using the Directory, Component, File, ServiceInstall and (if desired) ServiceControl elements.