|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
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.
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.
To specify a registry search as a launch condition
On the View menu, point to Editor, and then click Launch Conditions.
Select the Requirements on Target Machine node.
On the Action menu, choose Add Registry Launch Condition.
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.
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.
Select the Value property and type the registry value to search for.
For example, to search for Internet Explorer, type Path.
Select the Property property and type a meaningful name for the property.
For example, for the Internet Explorer search, type SearchForIE.
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
On the View menu, point to Editor, and then click File System.
In the File System Editor, select the File System on Target Machine node.
On the Action menu, point to Add Special Folder, and then click Custom Folder.
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).
When referencing a property in any property other than the Condition property, the square brackets are required.
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.