How do I install to the current user's ApplicationData folder? For example, I would like to install some files to <user profile>\Application Data\PhotoWorks\SomeApp.
In order to install files to each user's profile, a self-repair of the application must occur. The component containing the file must also contain an HKCU registry key as the key path.
Perform the following to install a file to a folder in the user's profile and allow a self-repair to occur for other users of the application:
If you are placing the file directly in the user's profile (and not in the Application Data directory) complete steps 1–3. If you are putting the file in the Application Data directory or a sub-folder skip to step 4
- On the files page, add your file to a "placeholder" directory, such as MyProfile directly under the Destination Computer.
- Go to the MSI Script > Execute Immediate tab.
- After CostFinalize add a Set Directory custom action with the following values:
- Custom Action Name: Unique name for this custom action
- Directory: Click Browse and select the MyProfile directory
- Directory Value: [%USERPROFILE]\FolderName
- Go to Setup Editor > Components tab, and find the component that contains your file. Usually this will be the name of the file
- Right-click the component and select New > Registry Key. A Registry item with empty registry hives appears
- Right-click HKEY_CURRENT_USER and select New > Registry Key.
- Enter the information for the key you wish to create. For example:
- Operation: Create/update key and value
- Root: HKEY_CURRENT_USER
- Key: Software\MyApplication
- Value Name: Repair UserProfile files
- Data Value: 1
- Data Type: String
- Right-click the component and select details. The Component Details dialog appears.
- In the Key Path Type field, select Registry Key Path. This should update the Reg. Key Path field to contain the registry key you just created.
After installing the application, when you log on as a new user, a repair should occur because the HKCU key does not exist. When this repair occurs the file should also be installed to the specified directory in the user's profile.
Rate this Article