Home > Windows Development > Simulating an OR Condition in the Bootstrapper Package

Simulating an OR Condition in the Bootstrapper Package

The installation bootstrapper created by the GenerateBootstrapper task in Visual Studio does not have support for compound conditions in the product.xml file. There is however a way to simulate an OR condition as I did with a product that required either Excel version 12 or 14 to be installed.

If you read carefully the description of the RegistryFileCheck you will notice that it says, “If this key does not exist, Property is not set.” That subtle, but very important statement started me thinking. If I were to do two or more RegistryFileChecks into the same property, would it indeed leave the results of the first check if the second key were absent? Yes, it does. Below is an example of how to use this information to determine if Excel 12 or 14 is installed.

<InstallChecks>
  <RegistryFileCheck Property=”ExcelVersion”
    Key=”HKLM\Software\Microsoft\Office\12.0\Excel\InstallRoot”
    Value=”Path” FileName=”EXCEL.EXE” SearchDepth=”0″ />
  <RegistryFileCheck Property=”ExcelVersion”
    Key=”HKLM\Software\Microsoft\Office\14.0\Excel\InstallRoot”
    Value=”Path” FileName=”EXCEL.EXE” SearchDepth=”0″ />
</InstallChecks>

The two checks above leave the property ExcelVersion in one of two states. Either it will contain the version of the higher version of Excel that is installed or it will be “NotExists” if both version 12 and 14 are absent

Once you have the “ExcelVersion,” it is easy to use to fail the installation if neither version of Excel is installed. Add the following to the InstallConditions portion of the Commands in the product.xml file.

<FailIf Property=”ExcelVersion”
  Compare=”ValueNotExists” String=”Excel2007SP2″/>

Advertisements
Categories: Windows Development Tags:
  1. 2012/06/07 at 08:37

    Heya, I just hopped over to your web site through StumbleUpon. Not somthing I might usually browse, but I enjoyed your views none the less. Thank you for making some thing worth reading through.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: