WiX: How to execute a command line command after installation

◇◆丶佛笑我妖孽 提交于 2019-12-06 21:04:06

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/26378382/wix-how-to-execute-a-command-line-command-after-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!