How do I create a folder directly under the user's profile folder or other locations that can be retrieved through an environment variable on the machine?
There may be occasions when files in your installation package pertain to the user currently logged onto the computer. These may be user-specific data files or text files that vary from user to user that your application updates.
Althrough the steps below are specific to using the USERPROFILE environment variable to create a directory in that path, these steps can also be used for any environement variable that is on the users machine, in the same manner.
To create a folder under the user's profile folder, complete the following steps:
- Open Wise for Windows Installer, Wise for Visual Studio .NET, or Windows Installer Editor in Wise Package Studio.
- Select Tools > Options. The Wise Options dialog appears.
- Click the Installation Expert tab and, if not all ready marked, mark the View directory for all features on Files page checkbox. Click OK.
- Select the Files page in Installation Expert.
- Add the files that you need installed to the user's profile into a new directory.
- Select View > MSI Script.
- Select Normal Installation from the Installation Mode drop-down list.
- Click the Execute Immediate tab.
- Click the line after CostFinalize.
- In the Actions list, double-click Set Directory. The Set Directory dialog appears.
- On the Details tab, enter the following information:
* Custom Action Name: SetPROFILE
* Directory: Browse for folder created in Step 5.
* Directory Value: [%USERPROFILE]\ where should be replaced with the name of the folder you want to create.
- Click OK.
At runtime, the installation resolves the value of the environment variable USERPROFILE and appends the folder name to this location. The folder is then created and the files you placed into this folder at design time are installed.