如何确定现有应用程序的安装范围?
How to determine install scope of existing app?
我有一个基于 WixUI_Advanced
的安装程序,允许用户选择他们的安装范围(每个用户或机器范围)。
升级时(安装了较低版本的现有应用程序)我想隐藏安装范围屏幕并自动 select 他们上次选择的安装范围。
如何判断上次安装使用的安装范围?
编辑
查看我的 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
和 MIGRATE
属性只有在现有安装的范围与当前安装的范围匹配时才设置,这是有道理的。也许我可以直接使用 FindRelatedProducts
?
This is not a complete answer. I had to add as an answer because of
formatting requirements.
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 Automation:这里有一个小技巧,可以在盒子上找到以前安装的产品(这基本上运行s 类似于 MSI 文件中 "FindRelatedProducts"
的内容):
微星内部:
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-sequence做这样的事情,但是运行又没时间了:
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
将在正在安装的新设置中设置。 See this answer for more。您可以使用 属性 来确定是隐藏还是显示按钮。我对其进行了简要测试并且它有效,但在 WiX 中实现它更难。我认为您需要覆盖整个对话框。
在 MSI 表中,它会像这样(Orca 屏幕截图 - ):
- Here is an answer on MSI and Burn GUI issues(请检查第 2 部分:
Change Default Dialogs - Advanced Dialogs
)。
添加更多链接:
- Removing Default dialogs from MSI
- Wix, custom dialog when previous version exists
- Back/Next Button in UI using Wix toolset
- http://neilsleightholm.blogspot.com/2008/08/customised-uis-for-wix.html
我最终检查了 DisplayName
与我们在注册表中的应用程序名称相匹配的条目(受 this answer 启发):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
然后我抓取了InstallLocation
的内容来确定安装范围:
if (installLocation == string.Empty)
{
// Installed before we introduced scope => never set install location
return ExistingInstallation.MachineWide;
}
else if (installLocation.Contains(_programFilesPath))
{
return ExistingInstallation.MachineWide;
}
else
{
return ExistingInstallation.UserSpecific;
}
我有一个基于 WixUI_Advanced
的安装程序,允许用户选择他们的安装范围(每个用户或机器范围)。
升级时(安装了较低版本的现有应用程序)我想隐藏安装范围屏幕并自动 select 他们上次选择的安装范围。
如何判断上次安装使用的安装范围?
编辑
查看我的 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
和 MIGRATE
属性只有在现有安装的范围与当前安装的范围匹配时才设置,这是有道理的。也许我可以直接使用 FindRelatedProducts
?
This is not a complete answer. I had to add as an answer because of formatting requirements.
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 Automation:这里有一个小技巧,可以在盒子上找到以前安装的产品(这基本上运行s 类似于 MSI 文件中 "FindRelatedProducts"
的内容):
微星内部:
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-sequence做这样的事情,但是运行又没时间了:
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
将在正在安装的新设置中设置。 See this answer for more。您可以使用 属性 来确定是隐藏还是显示按钮。我对其进行了简要测试并且它有效,但在 WiX 中实现它更难。我认为您需要覆盖整个对话框。
在 MSI 表中,它会像这样(Orca 屏幕截图 -
- Here is an answer on MSI and Burn GUI issues(请检查第 2 部分:
Change Default Dialogs - Advanced Dialogs
)。
添加更多链接:
- Removing Default dialogs from MSI
- Wix, custom dialog when previous version exists
- Back/Next Button in UI using Wix toolset
- http://neilsleightholm.blogspot.com/2008/08/customised-uis-for-wix.html
我最终检查了 DisplayName
与我们在注册表中的应用程序名称相匹配的条目(受 this answer 启发):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
然后我抓取了InstallLocation
的内容来确定安装范围:
if (installLocation == string.Empty)
{
// Installed before we introduced scope => never set install location
return ExistingInstallation.MachineWide;
}
else if (installLocation.Contains(_programFilesPath))
{
return ExistingInstallation.MachineWide;
}
else
{
return ExistingInstallation.UserSpecific;
}