windows-7 - WiX msi 自定义操作无法在 Windows 7 上以有限权限运行

标签 windows-7 visual-studio-2012 wix windows-installer custom-action

一直在尝试为我的最新项目创建一个 WiX 安装程序。我有一个奇怪的问题,如果我通过 cmd 提示符以管理员身份运行 msi,它工作正常,自定义操作会毫不费力地启动,一切正常,但如果我双击 msi,自定义操作将不起作用并且安装程序失败。我使用的是 Visual Studio 2012 和 Windows 7。

<!--Custom Actions-->
<Binary Id='customShortcut' SourceFile='$(var.CustomDir)\TestInstallerCustom.CA.dll'/>
<Binary Id='customDir' SourceFile='$(var.CustomDir)\TestInstallerCustom.CA.dll'/>
<Binary Id='removeDir' SourceFile='$(var.CustomDir)\TestInstallerCustom.CA.dll'/>

<CustomAction Id='customShortcutId' BinaryKey='customShortcut' DllEntry='CustomShortcut'
              Execute='immediate' Impersonate='no' Return='check' />
<CustomAction Id='customDirId' BinaryKey='customDir' DllEntry='CustomDir'
              Execute='immediate' Impersonate='no' Return='check'/>
<CustomAction Id='removeDirId' BinaryKey='removeDir' DllEntry='RemoveDir'
              Execute='immediate' Impersonate='no' Return='check'/>

<InstallExecuteSequence>
  <Custom Action='customDirId' Before='InstallFinalize'/>
  <Custom Action='customShortcutId' After='InstallFinalize'/>
  <Custom Action="removeDirId" After="InstallValidate">REMOVE="ALL"</Custom>
</InstallExecuteSequence>

最佳答案

安装的提升部分不会执行'immediate'自定义操作。因此,它们仅在安装过程中运行提升(如您所见)。要提升自定义操作,它们必须是事务脚本的一部分。为此,请设置 CustomAction 元素 Execute='deferred' 属性。

注意:延迟的自定义操作具有 MSI SDK 中记录的其他限制:'Deferred Execution Custom Actions' topic 。由于自定义操作看起来正在修改计算机状态,因此您还需要考虑添加回滚自定义操作以撤消延迟自定义操作所做的更改。

写好自定义操作非常具有挑战性。这就是为什么自定义操作是导致安装失败的最大原因的部分原因。如果您可以避免编写自定义操作,我强烈建议您这样做。 :)

关于windows-7 - WiX msi 自定义操作无法在 Windows 7 上以有限权限运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15893627/

相关文章:

javascript - IE11 F12 调试器未附加

WIX Heat,通过heat改变子目录的名称?

wix - 如何根据磁盘大小动态修改 Wix DiskCostDlg 消息?

windows-7 - DOSBox 退出错误 : CPU_SetSegGeneral: Stack segment zero

c++ - 为什么 MinGW 的 std::to_string() 运行速度比 VS2012 慢 16 倍

visual-studio-2010 - SharePoint - 在没有共享点服务器的独立计算机上进行开发

应用程序启动时 ASP.NET WebForms "Length cannot be less than 0 or exceed input length."

wix - Wix 中的嵌套变量

windows - Windows批处理文件中的过滤参数

c++ - 使用 RasDial 建立 VPN 连接后,是否要防止网络定位向导弹出?