How can I search for a directory and based on the results set that directory to the default location?
For this procedure you will need to perform a System Search to find a file within that directory. You can then create a condition based on that result and use the Set Directory action to set that Search property to the default directory.
2. In the Property field either select a predefined property or add your own. The property musts be in all uppercase. Example: TEST
3. Choose Search for file: return containing directory only from the Operation Drop down.
4. You can leave the Search Directory blank to search all directories or add a specific directory to search.
5. Add the depth of the directory you would like to search. 0 means it searches only the root folder.
6. Type the name of the File that you are searching for in the directory.
7. click Ok.
8. Go to MSI Script.
9. Under the User interface tab find the predefined action AppSearch. Move this to the top above LaunchConditions.
10. In the Execute Immediate Tab move the AppSearch action up as well.
*The following steps will be placed in either the User Interface or the Execute Immediate tab. It depends on whether you are running this silently or having the dialogs display. If you plan on running this silently you will need to place this action in the Execute Immediate Tab below CostFinalize. If you are going allow the end user to see dialogs you will place this in the User Interface Tab below CostFinalize.
11. Below CostFinalize create an If Statement. The Statement should read "If <The property used in the System Search> then. Example using Step 2 property: If TEST then. The property must be in all uppercase.
12. After this IF statement use the Set Directory Action.
- Enter the Name of the Custom Action you would like this to be called
- In the directory type INSTALLDIR. This is the property for the default directory.
- In Directory value type [SEARCH PROPERTY]. Example [TEST]. Must be in brackets and upper case.
- This will take the directory that is placed in the property and set it to the default directory.
13. Click Ok.
14. Use the End action to close out the If Statement.15. Statement should look like this: 16. Compile and run. If the file is found, the directory containing the file will be changed to the default directory. If the file is not found the default directory will remain what your MSI has originally set it to.