如何确定现有应用程序的安装范围?

2024-04-12

我有一个基于的安装程序WixUI_Advanced允许用户选择安装范围(每个用户或机器范围)。

升级时(安装了较低版本的现有应用程序)我想隐藏安装范围屏幕并自动选择他们上次选择的安装范围。

如何判断先前安装使用的安装范围?


Edit

查看我的 MSI 日志,我可以看到我现有的安装已找到:

// Existing user specific installation
FindRelatedProducts: Found application: {C5D3DCD0-4A97-4224-AF22-BDDEB357EEB7}
MSI (c) (C4:F0) [11:11:39:289]: PROPERTY CHANGE: Adding WIX_UPGRADE_DETECTED property. Its value is '{C5D3DCD0-4A97-4224-AF22-BDDEB357EEB7}'.
MSI (c) (C4:F0) [11:11:39:289]: PROPERTY CHANGE: Adding MIGRATE property. Its value is '{C5D3DCD0-4A97-4224-AF22-BDDEB357EEB7}'.

// Existing machine wide installation
MSI (c) (2C:4C) [11:03:19:258]: FindRelatedProducts: current install is per-user.  Related install for product '{C5D3DCD0-4A97-4224-AF22-BDDEB357EEB7}' is per-machine.  Skipping...

我可以看到WIX_UPGRADE_DETECTED and MIGRATE仅当现有安装的范围与当前安装匹配时才设置属性,这是有意义的。也许我可以用FindRelatedProducts直接地?


这不是一个完整的答案。我必须添加作为答案,因为 格式要求。


UPDATE: 看了这个,又没时间了。This really is no answer at all, but just lobbing it to you in case it can help you research it yourself.

注册表持久化: 我想你已经尝试过坚持了ALLUSERS和/或注册表中的安装范围并在更新的 MSI 中读回它?我没看那个。为此,您必须在软件包的第一个版本中执行此操作,并在以后保持它。

MSI API 自动化:这里有一个小技巧,可以找到盒子上以前安装的产品(这基本上运行类似的东西"FindRelatedProducts"在 MSI 文件内):

微星内部:

Set upgrades = Session.installer.RelatedProducts("INSERT-UPGRADE-CODE")
For Each u In upgrades
    scope = Session.installer.ProductInfo(u,"AssignmentType")
    MsgBox CStr(scope)
Next

单机,直接运行脚本(首先安装指定升级代码的MSI):

Set installer = CreateObject("WindowsInstaller.Installer")
Set upgrades = installer.RelatedProducts("INSERT-UPGRADE-CODE")

For Each u In upgrades
   MsgBox "Product Code: " & u & vbNewLine & "Installation Context: " & installer.ProductInfo(u,"AssignmentType")   
Next

MsgBox "Done"

我本想在 GUI 序列中做类似的事情,但又没时间了:

If scope = 1 Then
  Session.Property("ALLUSERS") = "1"
  Session.Property("MSIINSTALLPERUSER") = ""
  Session.Property("WixAppFolder") = "WixPerMachineFolder"
Else
  Session.Property("ALLUSERS") = "2"
  Session.Property("MSIINSTALLPERUSER") = "1"
  Session.Property("WixAppFolder") = "WixPerUserFolder"
End If

WiX 片段:

<Binary Id='Scope.vbs' SourceFile='Debugging Custom Actions\Scope.vbs' />
<CustomAction Id='Scope.vbs' VBScriptCall='' BinaryKey='Scope.vbs' Execute='immediate' Return='ignore'/>

<..>

<InstallUISequence>
  <Custom Action='Scope.vbs' Before='CostInitialize' />      
</InstallUISequence>

我本来想看看这个,但是没时间了。本质上WIX_UPGRADE_DETECTED将在正在安装的新安装程序中进行设置。请参阅此答案了解更多信息 https://stackoverflow.com/a/51090120/129130。您可以使用该属性来确定是隐藏还是显示按钮。我简单地测试了一下,它确实有效,但在 WiX 中实现它更困难。我认为你需要覆盖整个对话框。

在 MSI 表中,它会是这样的(Orca 屏幕截图 -MSI 查看器工具 https://stackoverflow.com/a/48482546/129130):


  • 这是关于 MSI 和 Burn GUI 问题的解答 https://stackoverflow.com/questions/52654935/changing-text-color-to-wix-dialogs/52674815#52674815(请检查第 2 部分:Change Default Dialogs - Advanced Dialogs).

添加更多链接:

  • 从 MSI 中删除默认对话框 https://stackoverflow.com/questions/52446750/removing-default-dialogs-from-msi/52451051#52451051
  • Wix,以前版本存在时的自定义对话框 https://stackoverflow.com/questions/33690724/wix-custom-dialog-when-previous-version-exists/52765526#52765526
  • 使用 Wix 工具集的 UI 中的后退/下一步按钮 https://stackoverflow.com/questions/56757662/back-next-button-in-ui-using-wix-toolset/56761784#56761784
  • http://neilsleightholm.blogspot.com/2008/08/customized-uis-for-wix.html http://neilsleightholm.blogspot.com/2008/08/customised-uis-for-wix.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何确定现有应用程序的安装范围? 的相关文章

随机推荐