我正在尝试让我们的 MSI 为非管理员用户工作。
我正在使用 WixUI_Advanced
,但即使我选择“仅为您安装”,我仍然收到管理提示:
查看 MSI 日志,我可以看到需要提升,但我不知道为什么:
MSI (s) (68:54) [10:45:25:359]: Product not registered: beginning first-time install
MSI (s) (68:54) [10:45:25:359]: PROPERTY CHANGE: Deleting ALLUSERS property. Its current value is '1'.
MSI (s) (68:54) [10:45:25:359]: Product {32799511-D146-40F4-ACA7-5A76E6E38854} is not managed.
MSI (s) (68:54) [10:45:25:359]: Machine policy value 'AlwaysInstallElevated' is 0
MSI (s) (68:54) [10:45:25:359]: User policy value 'AlwaysInstallElevated' is 0
MSI (s) (68:54) [10:45:25:359]: MSI_LUA: Elevation required to install product, will prompt for credentials
知道为什么系统会提示我授予管理员权限吗?
编辑
我创建了一个空的 Wix 项目,使用了 WixUI_Advanced
UI,但我遇到了同样的问题:/
最佳答案
Admin Rights Prompt: In the WiX sample below, elevation will be requested and required for per-machine installation, but not for per-user installation.
注意:我个人不喜欢按用户设置。在我的主观看来,我发现它们是边缘反模式。它与较差的可维护性(升级、修补等)以及许多其他细节有关,例如可疑的文件夹重定向和其他一些“高度惊讶”的因素。高级安装人员也很好地总结了一些限制:Advanced Installer: per-user setup limitations .
WiX Issue 5481 : 我添加了一个答案,但又删除了。它不能正常工作。我查看了 WiX 问题数据库,这是一个已知问题:https://github.com/wixtoolset/issues/issues/5481 。 NicMay 的最后一条评论看起来很有趣。我在下面制作了一个快速模型,结合了他/她的建议并进行了一些修改。
免责声明:以下示例存在许多缺陷,仅用作 "runnable sample"
。由于我使用的快捷方式快速解决方案,MSI 验证存在问题(使用快捷方式查看文件的安装位置,右键单击并转到 "Properties"
)。 "Create New Folder"
自定义安装对话框中的按钮也有一个错误。我仍然会发布它,看看是否对您有帮助:
NB!: Create new WiX project, add reference to
WixUIExtension.dll
, then follow comments. Run setup and click"Advanced"
to select per-user or per-machine install.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--CHANGE #1: Add an UpgradeCode GUID below -->
<Product Id="*" Name="PerUserOrPerMachine" Language="1033" Version="1.0.0.0"
Manufacturer="Hobbit" UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="PerUserOrPerMachine" Level="1" />
<!--CHANGE #2: Here we channel "hacker" NicMay with his / her dialog event tweaks mentioned in the WiX issue 5481 -->
<UI>
<UIRef Id="WixUI_Advanced" />
<Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1" Order="3">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="{}" Order="2">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="WixSetDefaultPerMachineFolder" Order="3">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="WixSetDefaultPerUserFolder" Order="3">WixAppFolder = "WixPerUserFolder"</Publish>
</UI>
<Property Id="ApplicationFolderName" Value="PerUserPerMachine" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<!--CHANGE #3: Add components and files as appropriate -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!--CHANGE #4: Make sure DesktopFolder is defined -->
<Directory Id="DesktopFolder" />
<Directory Id="ProgramFilesFolder">
<!--CHANGE #5: Crucial: Make sure Directory Id is APPLICATIONFOLDER (referenced elsewhere) -->
<Directory Id="APPLICATIONFOLDER" Name="PerUserOrPerMachine">
<Component Feature="ProductFeature" Guid="{5A74A1EE-0AD3-4C48-9E6B-4E4E3712A8BB}">
<!--CHANGE #6: Hard coded path below for simplicity, change path or replace construct -->
<File Source="D:\My Test Files\MyTestApplication.exe">
<Shortcut Id="AppDesktopShortcut" Name="PerUserOrPerMachine" Directory="DesktopFolder" />
</File>
<RegistryValue Root="HKCU" Key="Software\My Company\My Product" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Product>
</Wix>
链接:
- WiX Simple Setup Per User Installer (示例每用户设置 - 不应直接安装到用户配置文件文件夹,而是将安装设置为 ProgramFiles,然后允许 MSI 进行文件夹重定向)。
关于wix - 为什么我的 MSI 提示需要管理员权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56400973/