使用Advanced Installer打包工具如何设置是否安装预安装程序包

  要保证我们的程序能在目标机器上正常运行,便需要保证目标机器上提供了程序运行的必要组件。

  而在使用Advanced Installer打包工具制作程序安装包时,我们可以通过配置“需求-运行环境-程序包-预安装”来达到这一目的。

使用Advanced Installer打包工具如何设置是否安装预安装程序包

  如上图所示,我的程序需要.NET和VC++组件才能正常运行。那么我可以右键点击“预安装”,选择“新建包的运行环境”,将这些组件添加到“预安装”下面。于是我的安装包在安装时,优先安装“预安装”下面的组件包。

使用Advanced Installer打包工具如何设置是否安装预安装程序包

  此时,便衍生出了一个问题。若目标机器上安装了这些组件,则会进行重复安装,甚至组件安装失败等情况。如何检测目标机器是否安装过组件呢?下面以.NET Framework 4.6.1和Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215为例来说明如何配置检测机制。

  1.检测机器上是否安装.NET Framework 4.6.1。

  使用Advanced Installer打包工具如何设置是否安装预安装程序包  上述条件表示,若没有找到符合条件的项,则安装.NET Framework 4.6.1。接下来说说如何设置条件。

  首先,选择“安装基本的必须组件”(会自动插入一条无效默认条件),点击“编辑”按钮,会弹出如下图所示的界面。

使用Advanced Installer打包工具如何设置是否安装预安装程序包

  “标准”选择“有指定内容的注册表值”,注册表值选择“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release”。如下图所示:

使用Advanced Installer打包工具如何设置是否安装预安装程序包

  在“内容”栏中,“值”栏位填“394270”,“比较”栏位选择“大于”。这个条件的意思是:检测目标机器中是否安装了.NET Framework 4.6.1及以上版本。为什么值是394270,因为394271代表.NET Framework 4.6.1。上图中528040(十六进制0x00080ea8)表示目标机器安装的是.NET Framework 4.8版本。下面提供一张官方.NET Framework的Release DWORD值说明表。

使用Advanced Installer打包工具如何设置是否安装预安装程序包

 

  2.检测机器上是否安装Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215

  重复的动作不再多做赘述。下面直接说说如何配置Microsoft Visual C++ 2015 Redistributable的检测条件。

  点击“编辑”,打开如下界面:

使用Advanced Installer打包工具如何设置是否安装预安装程序包

  点击“注册表值”中的“...”选择按钮,打开注册表界面,选择Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215代表的项,如下图所示:

使用Advanced Installer打包工具如何设置是否安装预安装程序包

  在“内容”栏位中,“值”填入文件夹名称(与“数据”栏位的值是相同的),“比较”选择“包含”,点击“确定”完成条件的添加。值得注意的是,Microsoft Visual C++ 2015 Redistributable与Microsoft Visual C++ 2017 Redistributable好像不能共存,因此在添加条件时,需要同时检测Microsoft Visual C++ 2015 Redistributable与Microsoft Visual C++ 2017 Redistributable,如果有了更高的版本,则不需要安装Microsoft Visual C++ 2015 Redistributable了。

  顺便提供一下各VC++组件信息:

Visual C++ 2005
Microsoft Visual C++ 2005 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182
Configuration: x64
Version: 6.0.2900.2180
Direct Download URL: https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x64.EXE

Microsoft Visual C++ 2005 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a
Configuration: x86
Version: 6.0.2900.2180
Direct Download URL: https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.EXE

Visual C++ 2008
Microsoft Visual C++ 2008 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D
Configuration: x64
Version: 9.0.30729.5677
Direct Download URL: https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x64.exe

Microsoft Visual C++ 2008 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0
Configuration: x86
Version: 9.0.30729.5677
Direct Download URL: https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe

Visual C++ 2010
Microsoft Visual C++ 2010 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F
Configuration: x64
Version: 10.0.40219.325
Direct Download URL: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe

Microsoft Visual C++ 2010 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A
Configuration: x86
Version: 10.0.40219.325
Direct Download URL: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe

Visual C++ 2012
Microsoft Visual C++ 2012 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}
Configuration: x64
Version: 11.0.61030.0
Direct Download URL: https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe

Microsoft Visual C++ 2012 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}
Configuration: x86
Version: 11.0.61030.0
Direct Download URL: https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe

Visual C++ 2013
Microsoft Visual C++ 2013 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f}
Configuration: x64
Version: 12.0.30501.0
Direct Download URL: https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe

Microsoft Visual C++ 2013 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}
Configuration: x86
Version: 12.0.30501.0
Direct Download URL: https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe

Visual C++ 2015
Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.24215
Registry Key: HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Dependencies\{d992c12e-cab2-426f-bde3-fb8c53950b0d}
Configuration: x64
Version: 14.0.24215.1
Direct Download URL: https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe

Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215
Registry Key: HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Dependencies\{e2803110-78b3-4664-a479-3611a381656a}
Configuration: x86
Version: 14.0.24215.1
Direct Download URL: https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x86.exe

Visual C++ 2017
Caveat: There's either a new 2017 registry convention being used, or it hasn't been finalized, yet. As I'm guessing the upper-most keys of: [HKEY_CLASSES_ROOT\Installer\Dependencies\,,amd64,14.0,bundle] and [HKEY_CLASSES_ROOT\Installer\Dependencies\,,x86,14.0,bundle]

are subject to change, or at least have different nested GUIDs, I'm going to use list the key that ends with a GUID.

Microsoft Visual C++ 2017 Redistributable (x64) - 14.11.25325
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\,,amd64,14.0,bundle\Dependents\{6c6356fe-cbfa-4944-9bed-a9e99f45cb7a}]
Configuration: x64
Version: 14.11.25325.0
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/11100230/15ccb3f02745c7b206ad10373cbca89b/VC_redist.x64.exe

Microsoft Visual C++ 2017 Redistributable (x86) - 14.11.25325
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\,,x86,14.0,bundle\Dependents\{404c9c27-8377-4fd1-b607-7ca635db4e49}]
Configuration: x86
Version: 14.11.25325.0
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/11100229/78c1e864d806e36f6035d80a0e80399e/VC_redist.x86.exe

 

上一篇:每日日报2021.3.12


下一篇:JVM-03-本地方法接口和本地方法栈