How to call a command line program in WiX

Markus Ott picture Markus Ott · Jul 10, 2013 · Viewed 9.6k times · Source

I want to call a command line program of OpenOffice in WiX. To do so, I created a custom action, as seen below:

<CustomAction Id="ca_RunOpenOfficeProgram" Return="check" Directory="TARGETDIR"  ExeCommand="cmd.exe /K &quot;C:\OpenOffice.org3\program\unopgk.com list --shared&quot;" />

The Custom Action is being run in an Install Execute Sequence:

<InstallExecuteSequence>            
  <Custom Action="ca_RunOpenOfficeProgram" Before="InstallFinalize" />
 </InstallExecuteSequence>

When running the resulting MSI-File, I receive the following error message in a command line:

Invalid command 'C:\OpenOffice.org3\program\unopkg.com' could not be found.

Well, of course, the command is available and I may run it from command line. But it just doesnt work if the command line is being called by WiX. It`s also notable that the part 'list --shared' is completely ignored.

Does anyone know what`s going on here?

Answer

Ralf Abramowitsch picture Ralf Abramowitsch · Jul 10, 2013

I would recommend using the ShellExecute custom action from the WiX toolset.

Here is the sample code:

<Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

Change the Value of property WixShellExecTarget to cmd.exe /K &quot;C:\OpenOffice.org3\program\unopgk.com list --shared&quot; and it should work.