Video Screencast Help
Symantec Appoints Michael A. Brown CEO. Learn more.

Creating a Conditional Component Installation

Created: 28 Mar 2007 • Updated: 11 Jun 2007
Language Translations
ademeijer's picture
0 0 Votes
Login to vote

Ever wanted to create an install which installs a file/registry key only when a certain condition is true? Have a look at this article which provides step by step instructions on how to create a conditional component installation.

Task :

Depending on the value in the registry HKLM\Software\WiseWare\Department, installs either a file named FileA.txt (when the value is "sales") on the user's desktop or a FileB.txt (when the value is "support") on the user's desktop.

Objective:

Show the students how to have a conditional installation on a component level, which can be used for platform hybrid packages (w98/w2k etc).

Solution A (Condition on component):

  1. Create two dummy text files FileA.txt and FileB.txt in c:\temp
  2. Create a registry key in HKLM\Software\WiseWare with a String value called "department" and the data value of "support"
  3. Start the windows installer editor and create a new windows application
  4. On the files page, add both FileA.txt and FileB.txt to the destination's computer desktop.
  5. Go to the setup editor page and select the components tab.
  6. The two files should be in the same component as shown below
  7. Rename the Component to FileA, create a new component called FileB
  8. Set the directory to Windows\Profiles\Desktop and drag and drop FileB.txt from component FileA into component FileB
  9. Set FileB as keypath of its component
  10. Go to the product tab -> properties and create a property called "SEARCHRESULT"
  11. In installation expert go to the system search page and add a registry search, select the property "SEARCHRESULT", set the operation to "Read raw value from registry" and fill in the correct key to read as shown in the figure below.
  12. Go Back to setup editor select the details for component FileA and enter the following condition SEARCHRESULT ="sales", select the details for component FileB and enter the following condition SEARCHRESULT ="support"
  13. Check in installation expert on the features page if the complete feature has two conditions added to it if it has, go ahead and compile and test your MSI.

Solution B (Condition on feature)

Instead of putting the condition on a component, one can also build the condition on a feature. This is more convenient when one has to put the condition on a multiple of components.

  1. First you have to declare a property in which you store the search results.
  2. In Setup editor go to the product tab -> properties and create a property called "SEARCHRESULT"
  3. In installation expert go to the system search page and add a registry search, select the property "SEARCHRESULT", set the operation to "Read raw value from registry" and fill in the correct key to read as shown in the figure below.
  4. Then in Installation expert, go to the features page and create two features (e.g. Sales and Support)
  5. Then add the following condition to the Sales feature:
    SEARCHRESULT~="sales"
    

    And to the support feature

    SEARCHRESULT~="support"
    
    NOTE: The tilde (~) makes the condition case-insensitive:
  6. Now go to the files page and select in the current feature the sales condition as shown below:
  7. Now simply add the Sales.txt file to this feature
  8. For the support file you will select the support condition feature and add the support file subsequently.
  9. This will automatically create two different components with an installation condition on them.
Article Filed Under: