Wix 设置自定义事件不提示管理员权限

Wix setup custom event not prompt for admin rights

我正在尝试使用 WIX 设置自定义操作注册端口。检查下面的代码,

<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>

现在的问题是,当我开始执行 .msi 文件时,它会提示我输入管理员凭据以开始安装,但是当涉及到使用自定义操作注册端口时,命令 window 被打开但是该端口没有得到注册,它给出了有关受限访问的错误。

首先我要提到的是,如果禁用回滚,提交阶段将不会触发。其次,我将使用 WiX Quiet Execute 自定义操作,以便您可以记录输出和许多其他原因。您要使用下面的 "Deferred execution" 示例。

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