WiX: How to execute a command line command after installation

Weatherman159 picture Weatherman159 · Oct 15, 2014 · Viewed 12.8k times · Source

I need to register an HTTP port after installation, but I guess this could be abstracted to generally executing any command line command. Here's what I've got so far:

<CustomAction Id="ExecPortOpen" Directory="INSTALLFOLDER" Execute="immediate" ExeCommand="cmd.exe &quot;netsh http add urlacl url=http://+:1234/ user=Everyone&quot;" Return="ignore" />
<InstallExecuteSequence>
<Custom Action="ExecPortOpen" After="InstallFinalize" />
</InstallExecuteSequence>

This just opens a command prompt mid-install and does nothing with it. I've tried adding /c (I have no idea what it does) inbetween cmd.exe and the command but that just opens and closes the command prompt without executing the command. How do I make this work? I'm using WiX 3.8.

Answer

Weatherman159 picture Weatherman159 · Oct 15, 2014

Solved myself, was actually an UAC/ permissions issue. For any interested parties here is the working code:

<CustomAction Id="ExecPortOpen" Directory="INSTALLFOLDER" Execute="commit" Impersonate="no" ExeCommand="cmd.exe /c &quot;netsh http add urlacl url=http://+:1234/ user=Everyone&quot;" Return="check" />

<InstallExecuteSequence>
  <Custom Action="ExecPortOpen" After="InstallInitialize" />
</InstallExecuteSequence>