默认情况下,每用户 MSI 未提升 - 如何显示写入文件夹的提升提示?

发布于 2025-01-05 01:47:29 字数 216 浏览 1 评论 0原文

我有一个通过 WiX 构建的 MSI,它是针对每个用户的,如果用户有权访问目标文件夹,则不会显示 UAC 提示。但是,如果目标文件夹位于 Program Files 中,则会出现“权限不足”错误。

如果目标文件夹不可写,如何显示 UAC 提示?

I have an MSI built via WiX, it's per-user and doesn't display the UAC prompt if the user has rights to the destination folder. However, if the destination folder is in Program Files, it errors with "Insuficient privileges".

How can I show a UAC prompt in the case the destination folder is not writable?

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

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

发布评论

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

评论(2

甜`诱少女 2025-01-12 01:47:29

事实并非如此。每用户安装永远不应该要求提升,也不应该写入程序文件,因为这是每台计算机的位置。相反,它应该安装到%LocalAppData%\Programs\Company\Product。

阅读以下内容以获取更多背景信息。部分适用,部分可能超出范围(每个用户/每台计算机的双重要求):

为以下内容编写单个包Windows 7 中的每用户或每计算机安装上下文

It doesn't really work that way. Per User installs should never require elevation and should never write to Program Files as that's a per machine location. Instead it should install to %LocalAppData%\Programs\Company\Product.

Read the following for a lot more background information. Parts apply and parts may be beyond scope ( dual per-user / per-machine requirements ):

Authoring a single package for Per-User or Per-Machine Installation context in Windows 7

万人眼中万个我 2025-01-12 01:47:29

我知道这是一个旧线程,但我想让遇到它的其他人知道这确实是可能的。

正如前面的答案中提到的,传统的每用户安装不需要管理员权限。但是,我遇到了一个完全有效的情况,我需要运行需要管理员权限的自定义操作。要求我的用户从具有提升权限的命令行使用 msiexec 启动 MSI 似乎不是一个可接受的解决方案。

这似乎并不那么困难,但幸运的是我偶然发现了 这篇文章:Package/@InstallScope 属性不支持每用户、提升的包!因此,只需在您的包定义中省略它:

<!-- NOTE: If you need to create a per-user installation (meaning it's not -->
<!-- visible in Add/Remove Programs from other logons) that prompts for -->
<!-- elevation, omit both the Package/@InstallPrivileges="elevated" and
<!-- Package/@InstallScope="perUser". -->
<Package InstallerVersion="200" Compressed="yes" />

也不要忘记将 ALLUSERS 保留为未定义。我在我的博客上进一步描述了这一点:

如何使用 WiX 提升每用户安装程序

I know this is an old thread, but I want to let others who come across it that it is indeed possible.

As was mentioned in the previous answer, conventional per-user installs should not require admin rights. However, I came across a perfectly valid situation where I needed to run a custom action which required admin rights. Requiring my users to launch the MSI with msiexec from a command line with elevated privileges did not seem like an acceptable solution.

It doesn't seem like this should be so difficult, but luckily I stumbled onto the answer in this post: The Package/@InstallScope attribute doesn’t support per-user, elevated packages! So just omit it in your Package definition:

<!-- NOTE: If you need to create a per-user installation (meaning it's not -->
<!-- visible in Add/Remove Programs from other logons) that prompts for -->
<!-- elevation, omit both the Package/@InstallPrivileges="elevated" and
<!-- Package/@InstallScope="perUser". -->
<Package InstallerVersion="200" Compressed="yes" />

Don't forget to leave ALLUSERS undefined, as well. I described this further on my blog:

How to Elevate a Per User Installer Using WiX

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