0

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.

Any suggestions would be greatly appreciated.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
user2437443
  • 2,067
  • 4
  • 23
  • 38

1 Answers1

2

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.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • Thanks for the reply, I tried that and it seems to be working, except on install, the installer gets stuck on "starting services". It never gets past that point. I've added the component to my original question, if you could take a look. – user2437443 Aug 28 '13 at 23:17
  • The target of the ServiceInstall element is the keyfile of the parent component. In your case that keyfile needs to be the Serveany.exe as it knows how to be a service. You're other EXE is really a companion file which is an argument to srvany.exe via the registry. – Christopher Painter Aug 29 '13 at 01:53