本文介绍了安装后执行需要提升的自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 WiX 片段:

I have the following WiX snippet:

<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<CustomAction Id="StartAppOnExit"
              FileKey="Configurator.exe"
              ExeCommand=""
              Execute="immediate"
              Impersonate="yes"
              Return="asyncNoWait" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT"
          Value="Configure initial settings" />
<UI>
  <Publish Dialog="ExitDialog"
           Control="Finish"
           Order="1"
           Event="DoAction"
           Value="StartAppOnExit"
  >WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>

基本上在退出对话框上,我会显示一个框,上面写着:启动应用程序.注意:此应用程序需要提升.这一切都很好,除了一个障碍.如果启用了 UAC,MSI 似乎会使用用户令牌并剥离其组,因此当它尝试启动需要提升的应用程序时,它不再是一个选项.

Basically on the exit dialog I display a box that says: launch application. Note: this application requires elevation. This all works fine except for a snag. If UAC is enabled it seems that the MSI mucks around with the user token and strips its groups, so when it tries to launch the application that requires elevation it is no longer an option.

我如何将它们串在一起才能工作?

How do I string this together to work?

我尝试放弃 Impersonate="no",但现在已经太迟了.

I tried chucking an Impersonate="no", but it's too late at that point for this to work.

推荐答案

UI 序列以受限用户身份运行,它通过调用 CreateProcess 启动应用程序.如果您使用类似 WixShellExec 之类的东西和 [WixShellExecTarget] 代替,如果目标需要提升,它将像资源管理器一样运行并显示 UAC 提示.或者您可以修改您的 Configurator.exe 以允许在没有提升权限的情况下启动,检测这种情况,然后使用提升的权限重新启动.

The UI sequence is running as a limited user, and it launches applications with a call to CreateProcess. If you use something like a WixShellExec with [WixShellExecTarget] instead, it will act like Explorer and show a UAC prompt if the target requires elevation. Or you could modify your Configurator.exe to allow being launched without elevated privileges, detect that case, and relaunch itself with elevated privileges.

例如,这应该有效:

<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
<CustomAction Id="StartAppOnExit" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes"/>
<Property Id="WixShellExecTarget" Value="[#Configurator.exe]"/>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Configure initial settings" />
<UI>
  <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="StartAppOnExit">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>

这篇关于安装后执行需要提升的自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 05:45