执行安装后需要提升的自定义操作

发布于 2024-08-22 12:56:01 字数 885 浏览 1 评论 0原文

我有以下 WiX 片段:

<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 似乎会处理用户令牌并剥离其组,因此当它尝试启动需要提升的应用程序时,它不再是一个选项。

我如何将其串联起来以发挥作用?

我尝试放弃 Impersonate="no",但此时已经太晚了,无法正常工作。

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>

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?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

漫漫岁月 2024-08-29 12:56:01

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

例如,这应该有效:

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

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.

For example, this should work:

<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>
卸妝后依然美 2024-08-29 12:56:01

仅供参考,立即自定义操作始终被模拟(即它们始终以执行 MSI 的用户身份运行)。

我喜欢 Michael Urman 关于让 Configurator.exe 处理海拔问题的想法。

我想知道您是否也可以在 EXE 中包含一个清单,以便操作系统知道始终需要提升。

FYI, Immediate custom actions are ALWAYS impersonated (i.e. they always run as the user who executes the MSI).

I like Michael Urman's idea regarding making your Configurator.exe handle the elevation issue.

I wonder if you could also just include a manifest in your EXE so that the OS knows elevation is always required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文