16

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.

Weatherman159
  • 565
  • 1
  • 4
  • 9
  • FYI, there will be a new Http extension for registering an HTTP port in WiX v3.10/4.0. http://wixtoolset.org/issues/4505/ – Sean Hall Oct 15 '14 at 23:29

1 Answers1

26

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>
Weatherman159
  • 565
  • 1
  • 4
  • 9
  • 5
    I searched so much all over the net, and you're the first that I found who pointed out that `Execute="commit"` will preserve UAC for `netsh` while `Execute="immediate"` runs in user mode. Thanks! – Stephen Chung Feb 11 '17 at 04:50
  • the Impersonate="no" did the trick, FYI [link](http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Running-cmd-exe-from-a-CustomAction-td696703.html) – Bill Hoo May 31 '18 at 09:36
  • I know we avoid useless comments but... THANK YOU @Weatherman159 !! – Christian Jun 07 '21 at 12:50