我试图在Windows Server 2008上的Wix安装程序中执行自定义操作,以授予绑定(bind)到HTTP套接字的权限。但是,该安装程序无法正常工作。

<CustomAction Id="GrantHttpPermission_Cmd" Property="GrantHttpPermission" Value="&quot;[SystemFolder]netsh.exe http add urlacl url=http://+:8732/ user=Service_account&quot;" Execute="immediate"/>
<CustomAction Id="GrantHttpPermission" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no"/>

...

<InstallExecuteSequence>
  <Custom Action="GrantHttpPermission_Cmd" After="CostFinalize"/>
  <Custom Action="GrantHttpPermission" After="ConfigureUsers">NOT Installed</Custom>
</InstallExecuteSequence>

在 Debug模式下运行安装程序,出现以下故障。我还尝试以管理员身份运行安装程序,并显示相同的输出
MSI (s) (14:20) [11:03:00:440]: Executing op: CustomActionSchedule(Action=GrantHttpPermission,ActionType=3073,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:\Windows\SysWOW64\netsh.exe http add urlacl url=http://+:8732/ user=Service_account")
MSI (s) (14:24) [11:03:00:440]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIF794.tmp, Entrypoint: CAQuietExec
CAQuietExec:  Error 0x80070002: Command failed to execute.
CAQuietExec:  Error 0x80070002: CAQuietExec Failed
CustomAction GrantHttpPermission returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 11:03:00: InstallFinalize. Return value 3.

任何人都可以阐明该命令的内容吗?

最佳答案

原来这与正确引用命令有关。 GrantHttpPermission_Cmd行需要将“移至可执行文件周围,而不是整个命令,并且不需要[SystemFolder]部分。最终命令如下所示:

<CustomAction Id="GrantHttpPermission_Cmd" Property="GrantHttpPermission" Value="&quot;netsh.exe&quot; http add urlacl url=http://+:8732/ user=Service_account" Execute="immediate"/>

所有其他命令都相同。

10-07 12:52