This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Set a Directory Table Entry at Run Time
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Set a Directory Table Entry at Run Time
Set a Directory Table Entry at Run Time
Summary
This article describes how to create a Directory table entry and set it through InstallScript in an MSI Project.Synopsis
This article describes how to create a Directory table entry and set it through InstallScript in an MSI Project.
Discussion
The following steps can be used to create a Directory table entry, and set it to a desired path via InstallScript.
- Open the Directory Table via the Direct Editor.
- Create the following row in the Directory table:
Directory Directory_Parent DefaultDir IsDescription IsAttributes MYDIR TARGETDIR . - Navigate to the InstallScript view and create a new script file.
- On the right side, you will fine a default function called MyFunction. Modify the function so that it looks like the following:
function MyFunction(hMSI) STRING svString; begin svString = "C:\\TestFolder"; //Two slashes are needed in order to define subdirectories in InstallScript. //Note: for the purposes of this script, the path has been hardcoded. //You must have an accessible C drive to run this script. //If you do not have a C drive then change the path to point to an accessible drive. MsiSetTargetPath(hMSI, "MYDIR", svString); end;
- Compile the script.
- Right-click Custom Actions in the Sequences/Action view.
- Select Custom Action Wizard from the context menu.
- Proceed through the wizard, and give the custom action a unique name.
- Select Run InstallScript code for the custom action type, and in the next panel, select MyFunction (or the new name of the entry-point function) for the source.
- Select Next, accepting the default selections until the wizard creates the custom action.
- Right-click the CostFinalize action in the User Interface or Execute sequence, and choose Insert.
- Select Custom Actions from the drop-down box provided, and choose your custom action.
- Put a condition of Not Installed on the custom action.
- Build a release and run the setup.
Additional Information
For more information on the functions discussed, see the Windows Installer Help Library topics MsiSetTargetPath and CostFinalize.
No ratings