Export (0) Print
Expand All

How to: Use a Registry Launch Condition to Specify a Target Directory 

A Registry launch condition can be used to search for a required registry key or value and display an error message if it is not found.

In addition to searching for the existence of a registry key or value, a registry search can be used to retrieve a value from the registry; that value can then be used to set a property in an installer during installation. For example, you might want to install a file in the same directory as Internet Explorer. There is no guarantee that Internet Explorer is installed in the same location on every computer; however, there is a registry key that specifies where it is located.

If the registry search fails to find a match (for example, if Internet Explorer is not installed), installation will fail. The launch condition evaluates the value returned by the registry search; if it is blank, then an error message is displayed.

The following example uses a registry search to determine the target directory for a file. Follow both procedures below: the first to specify a registry search as a launch condition; the second to install files based on the registry search.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To specify a registry search as a launch condition

  1. On the View menu, point to Editor, and then click Launch Conditions.

  2. Select the Requirements on Target Machine node.

  3. On the Action menu, choose Add Registry Launch Condition.

  4. Select the Search for RegistryEntry node. In the Properties window, select the Root property and select the registry root to be searched.

    For example, to search for Internet Explorer, choose vsdrrHKLM, which will search the HKEY_LOCAL_MACHINE root.

  5. Select the RegKey property and type the name of the registry key to search for.

    For example, to search for Internet Explorer, type SOFTWARE\Microsoft\IE Setup\Setup.

  6. Select the Value property and type the registry value to search for.

    For example, to search for Internet Explorer, type Path.

  7. Select the Property property and type a meaningful name for the property.

    For example, for the Internet Explorer search, type SearchForIE.

  8. Select the Condition node. In the Properties window, select the Condition property and type the name of the condition to evaluate. This should match the Property property entered for the registry search.

    For example, for the Internet Explorer launch condition, type SearchForIE.

To install files based on the registry search

  1. On the View menu, point to Editor, and then click File System.

  2. In the File System Editor, select the File System on Target Machine node.

  3. On the Action menu, point to Add Special Folder, and then click Custom Folder.

  4. In the Properties window, select the DefaultLocation property and type the property that specifies the location.

    For example, for the Internet Explorer launch condition, type [SearchForIE] (the value of the Property property for the registry search).

    NoteNote

    When referencing a property in any property other than the Condition property, the square brackets are required.

  5. When the installer is run, the value of the Property property will be evaluated and placed in the DefaultLocation property; the files will be installed in the location specified by that value.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft