Search code examples
wixadmincustom-action

Wix setup custom event not prompt for admin rights


I am trying to register port using WIX setup custom action. Check the code below,

<CustomAction Id="addPort" Directory="INSTALLFOLDER" Execute="commit" Impersonate="no" ExeCommand="[SystemFolder]netsh.exe http add urlacl http://*:1919/ user=Everyone" Return="check">
</CustomAction>
<InstallExecuteSequence>
  <Custom Action="addPort" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>

Now the issue is, while I am starting to execute .msi file, it will prompt me to enter admin credentials to start installation but when it comes to register port using custom action, command window gets open but the port is not getting register and it gives error regarding restricted access.


Solution

  • First I'd mention that commit phase won't fire if rollback is disabled. Second, I'd use the WiX Quiet Execute custom actions so you can get the output logged and a number of other reasons. You want to use the "Deferred execution" example below.

    http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html