Search code examples
wixcustom-action

My CustomAction to run an executable via WixShellExect is failing


I have built a wix but I am falling down at the last part where I run an application that allows users to communicate with the Windows Service I just installed. The install rolls back.

If I don't include the WixShellExec Custom Action then the exe installs and I can run the application from the install folder with no problem.

I have this in the Product.wxs file:

<!--Used to start the Console when install complete-->
<Component Id="Cmp_ArduinoControllerConsole" Directory="dir_Console" Guid="83D1FD64-0DE5-461B-997D-641C394999F1">
<File Id="File_ArduinoControllerConsole" KeyPath="yes" Source="$(var.MyDir)\Console\RJB.ArduinoController.Console.exe" />
</Component>

<!--Set up the action to run the console at the end of the installation -->
<Property Id="WixShellExecTarget" Value="[#File_ArduinoControllerConsole]" />
<CustomAction Id="Run_File_ArduinoControllerConsole" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

<!--Sets when in the install sequence the Custom Action runs-->
<InstallExecuteSequence>
    <Custom Action="Run_File_ArduinoControllerConsole" 
            Before="InstallFinalize" />
</InstallExecuteSequence>

I get an error in the Installation log:

MSI (s) (0C:34) [23:40:29:636]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI6179.tmp, Entrypoint: WixShellExec

WixShellExec:  Error 0x80070002: ShellExec failed with return code 2
WixShellExec:  Error 0x80070002: failed to launch target

CustomAction Run_File_ArduinoControllerConsole returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 23:40:29: Run_File_ArduinoControllerConsole. Return value 3.

Can anyone suggest what I've done wrong?


Solution

  • Solution.

    I could not get the value in Property:

    to produce a value so I changed the Custom action to this:

    <CustomAction Id='Launch_ArduinoControllerConsole' FileKey='File_ArduinoControllerConsole' ExeCommand='' Return='asyncNoWait' />
    

    and replaced it in this:

        <InstallExecuteSequence>
      <Custom Action='Launch_ArduinoControllerConsole' After='InstallFinalize'>NOT Installed</Custom>
    </InstallExecuteSequence>
    

    Which ran the executable after the install finished. The CustomAction setting Return='asyncNoWait' is the one to get right.

    If anyone finds out why the value in Property is wrong I'm intrigued to know but for now I have a fix.