0

I have a .Net WinForms application developed on .Net 4.0. (windows installer package). The application is dependent on SAP crystal report runtime and MS Access runtime. I need to check if these two prerequisites are installed on the user machine, if not then exit the installer with a dialog box saying installation failed due to missing prerequisites.

[Edit] The image below highlights the type of installer project that I'm working on. It is a old legacy application.

https://i.stack.imgur.com/6sbYe.png

[Edit 2] Here I have created "Search Target Machine" and created "Add Registry Search" - "Search for Crystal Report Runtime"

enter image description here

And created a new "Launch Conditions" under "Launch Conditions" called as "CrystalReportRuntimeInstalled". Somehow this condition is always evaluating to false even when the software is installed. What am i doing wrong?

enter image description here

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Sid
  • 123
  • 2
  • 10
  • [What tool are you using](https://stackoverflow.com/a/50229840/129130)? – Stein Åsmul Mar 15 '19 at 12:57
  • I'm new to creating the installer package. After browsing the internet for some time now, i have decided to use WiX toolset (as it is free). I don't intend to install the missing prerequisites but just hightlight (dialog box) that they are missing and that the installation would exit. Is it possible to to do this without using any tool? – Sid Mar 18 '19 at 07:46
  • Yes, this is what ``LaunchCondition`` is intended to support. Just a list of conditions that must be satisfied for the installation process to get off the ground. Unfortunately the conditions also apply to maintenance and uninstall operations, and this can cause packages that won't uninstall. See my description below. – Stein Åsmul Mar 18 '19 at 10:59
  • Did you get this resolved? – Stein Åsmul Mar 20 '19 at 12:59
  • yes Stein, thank you so much for your guidance. – Sid Mar 20 '19 at 13:57
  • @SteinÅsmul I have posted my answer below. Please review and let me know if i could do it better. Thanks – Sid Mar 20 '19 at 14:43

2 Answers2

0

UPDATE, since you want to use WiX:

WiX Quick Start: You can see how to implement launch conditions in WiX by checking out this nice real-world sample by Helge Klein: https://helgeklein.com/blog/2014/09/real-world-example-wix-msi-application-installer/ (WayBack - archived version).

There are more "WiX quick start suggestions" here. That includes more source code sample links and links of all kinds. It is an "ad-hoc answer" - in other words messy - that seems to help in the real-world. I still wonder why, if you can tell me whether that is true or not that would be good.

Quick, inline sample:

<Condition Message="The .NET Framework 2.0 must be installed">
    Installed OR NETFRAMEWORK20
</Condition>

LaunchCondition Table: The general mechanism for this is the LaunchCondition table. You add conditions here that must be satisfied (evaluate to true) for the package to allow installation operations (not just fresh install). You can use custom actions to inspect the system and set properties or you can use built-in MSI search mechanisms to set properties. The properties are then used in the condition specified.

LaunchCondition Problems: Conditions can accidentally evaluate to false on maintenance and uninstall operations. This is generally very undesirable. An example is a check for the presence of a runtime that can have been uninstalled manually and hence accidentally made the main MSI fail to uninstall or even upgrade. Example here (please read thoroughly).

Tweak:To ensure LaunchConditions only apply on fresh install (and major upgrades - which work as fresh installs technically), there is a trick to add "OR Installed" to the condition you need. Described here. To the Batmobile.

Example: Here is a row from a LaunchCondition table as example (Require .NET version 4.7):

Installed OR DOTNETVERSION471FULL>="#461308", Microsoft .NET Framework 4.7.1 Full package or greater needs to be installed for this installation to continue.

Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • thanks for helping me here. I took to your first approach by looking at the Launch Conditions. I realized that i do not want to create a new installer package and miss out on any checks performed by previous developers hence leaving out the WiX way and will continue to work on the already created installer file. I have made some edits to the questions and have added few more images. The issue i'm facing is that Launch Condition is always evaluating to false even when the Crystal Report Runtime is installed on the machine. What am i doing wrong? – Sid Mar 19 '19 at 11:59
  • Are you searching the right registry hive in terms of bitness? In other words `HKEY_LOCAL_MACHINE\SOFTWARE` (**`64-bit`**) versus `HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node` (**`32-bit`**). Use **`regedit.exe`** to check. – Stein Åsmul Mar 20 '19 at 00:10
0

So the way i had to check the registry value was to remove the name "CRRuntime32Version" from RegKey and add it to the "Value" section in the properties of Registry Search as shown in below image.

enter image description here Similarly i created two Registry Search for Microsoft Access Runtime 2013.

enter image description here Note: I created two different Registry Search based on bitness of a machine.

And modified the "Launch Condition" as shown below.

enter image description here Here is the complete "Condition" value set for Microsoft Access Runtime 2013. If there is a better way of checking then please let me know.

enter image description here After doing these changes i built the setup package. Uninstalled the prerequisites and the setup package from my target machine. And while trying to install the set up package got the prompt as shown below.

enter image description here

Sid
  • 123
  • 2
  • 10
  • You must eliminate the hard code paths. Instead of ``C:\Program Files\SomePath\File.txt``, you need to do for example: ``[ProgramFiles64Folder]SomePath\File.txt``. – Stein Åsmul Mar 21 '19 at 01:37
  • Please be careful to match the right folder hierarchy according to bitness. As in 32-bit: `C:\Program Files (x86)` and 64-bit: `C:\Program Files`. Same for the system: `C:\Windows (64-bit)`, and (amazingly) `C:\Windows\SysWOW64` is 32-bit. Ideally test on localized systems with different folder names and on all version of Windows that are valid for the package. – Stein Åsmul Mar 21 '19 at 11:00
  • Hello Stein, i tried using ACCESSRUNTIMEINSTALLED32="[ProgramFilesFolder]Microsoft Office\Office15\" instead of hard coding the path like ACCESSRUNTIMEINSTALLED32="C:\Program Files\Microsoft Office\Office15\" But this isn't working for me. – Sid May 03 '19 at 11:38