How do I distribute HKEY_CURRENT_USER (HKCU) keys to any user using self-repair?
To allow HKCU keys to be written for any user via the self-repair functionality, follow the guidlines below:
- Ensure that all HKCU registry keys are in their own component for each feature that requires HKCU keys. By default, Wise for Windows Installer (WFWI) will do this automatically unless you modify the components yourself. Do not have any files within the component containing your HKCU registry keys.
- Include an advertised access point in the same feature containing your HKCU keys so that the self-repair will be initiated. There are three methods to do this:
- Create an advertised shortcut. Typically, this will be to your main executable. This is by far the most popular way to implement advertising.
- Include file extension information. Self-repairs can be triggered if you have file extension information associated with an application that is installed with the MSI.
- Use advertising information associated with .DLLs. If an API call is made using a registered CLSID that contains advertising information this will initiate self-repair of the application.
- Add ALLUSERS into the Property table in Setup Editors Tables Tab and set the Value to 1.
Additional items to consider when designing your installation:
- Once an advertised access point has been initiated, Windows Installer will check the key paths of all of the components within the feature that contains the advertised access point.
- Key paths are set to a component in the Components tab of the Setup Editor. To check and set the key path, right-click on the component and select Details from the popup menu. Set the key path type and the key path.
- You can set the key path type to be a file, registry key, or ODBC data source.
- If all of the component key paths are present for that feature, Windows Installer proceeds with whatever it was doing, launching the shortcut for example. If a component key path is missing, as will be the case when a new user logs onto the computer, and the HKCU registry keys are missing, Windows Installer will proceed to check the key paths of all components in all the features of the MSI. The basic idea is that if Windows Installer finds one key path missing in the initial feature scanned, it will scan all the other features for additional missing key paths. Windows Installer will then have a complete assessment of which components need to be reinstalled.
- Windows Installer will begin to perform the self-repair. In most cases Windows Installer will repair the entire feature—reinstalling all of the components. Often, this will involve reinstalling files and the source MSI will be required. The exception to this case is with Windows Installer 2.0 when the service detects that only registry keys are missing and need to be reinstalled. If this is the case, Windows Installer will reinstall those registry keys using the information stored in the cached MSI held in the Windows\Installer or WINNT\Installer folder. This is why you should never include files in the same component as your HKCU registry keys. If you include files with the registry keys, Window Installer will still need the source MSI to reinstall the file(s) in the component even though registry keys may be the only piece missing from the installation.
- By default, when Windows Installer needs to reinstall files, the Windows Installer will try to find the source MSI in the same location from which the MSI was originally installed
- If it is no longer at that location or the user does not have sufficient permissions to access the source MSI, then Windows Installer will prompt the user to locate the source MSI for the repair.
- If the source MSI is unavailable to the user then the repair cannot be done.
If you did not use internally compressed .CAB files for your source, but instead used external .CABs or external uncompressed files the same ideas apply. Windows Installer will look for those .CABs or files where they were located at time of the original installation. This information is in the cached MSI's tables and if the .CABs or files are not found, the repair cannot occur.
This document assumes that you are using Windows Installer 2.0 which handles the self-repairing of HKCU keys more efficiently than previous versions of Windows Installer and that the target environment support the advertising functionality of Windows Installer. Refer to the Platform Support of Advertisement topic in the Windows Installer SDK for advertisement support details.
Imported Document Id