installation - 如何确定 Windows Installer 正在执行升级而不是首次安装?

标签 installation windows-installer

我有一个安装,如果应用程序退出,它会升级该应用程序的先前版本。当安装处于升级模式时,我想跳过某些操作。如何确定安装是在升级模式还是首次安装模式下运行?

我正在使用 Wise Installer,但我认为这并不重要。我假设 Windows Installer 有一个在安装程序处于升级模式时设置的属性。我只是似乎找不到它。如果该属性存在,我假设我可以在条件语句中使用它。

最佳答案

您能详细说明一下您使用什么类型的工具来创建此安装程序吗?

我使用 Windows Installer XML( WIX )。在 WIX 中你可以这样做:

  <!-- Property definitions -->
  <?define SkuName = "MyCoolApp"?>
  <?define ProductName="My Cool Application"?>
  <?define Manufacturer="Acme Inc."?>
  <?define Copyright="Copyright © Acme Inc. All rights reserved."?>
  <?define ProductVersion="1.1.0.0"?>
  <?define RTMProductVersion="1.0.0.0" ?>
  <?define UpgradeCode="{EF9D543D-9BDA-47F9-A6B4-D1845A2EBD49}"?>
  <?define ProductCode="{27EA5747-9CE3-3F83-96C3-B2F5212CD1A6}"?>
  <?define Language="1033"?>
  <?define CodePage="1252"?>
  <?define InstallerVersion="200"?>

并定义升级选项:

<Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Minimum="$(var.ProductVersion)"
              IncludeMinimum="no"
              OnlyDetect="yes"
              Language="$(var.Language)"
              Property="NEWPRODUCTFOUND" />

      <UpgradeVersion Minimum="$(var.RTMProductVersion)"
              IncludeMinimum="yes"
              Maximum="$(var.ProductVersion)"
              IgnoreRemoveFailure="no"
              IncludeMaximum="no"
              Language="$(var.Language)"
              Property="OLDIEFOUND" />

</Upgrade>

然后,您可以根据您想要执行的操作使用 OLDIEFOUNDNEWPRODUCTFOUND 属性:

<!-- Define custom actions -->
<CustomAction   Id="ActivateProduct" 
            Directory='MyCoolAppFolder' 
            ExeCommand='"[MyCoolAppFolder]activateme.exe"' 
            Return='asyncNoWait' 
        Execute='deferred'/>

<CustomAction   Id="NoUpgrade4U" 
            Error="A newer version of MyCoolApp is already installed."/>

上面定义的操作必须在InstallExcecuteSequence中定义

<InstallExecuteSequence>
    <Custom Action="NoUpgrade4U" 
        After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
    <Custom Action="ActivateProduct" 
        OnExit='success'>NOT OLDIEFOUND</Custom>
</InstallExecuteSequence>

关于installation - 如何确定 Windows Installer 正在执行升级而不是首次安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/145900/

相关文章:

installation - 在目标 PowerPC 机器上安装 Valgrind

windows-installer - Chromium - 如何使用 mini_installer.exe 制作一个实际的安装程序

java - 使用嵌入式 JRE 在 Mac OS 中创建 Windows 应用程序安装程序

c# - 什么时候使用 GAC?

.net - 如何修改内存中的 MSI?

c# - 在远程计算机上安装 msi (ManagementException "Not found")

c# - 如何复制与安装程序位于同一目录中的文件

web-applications - Chrome 应用程序快捷方式/Mozilla Prism 安装程序

hadoop - 如何在Hadoop-3.2.0中删除ERROR start-dfs.sh

python - 将 ScientificPython 安装为依赖项