Summary
This article describes how to create an InstallScript Custom Action that detects and displays a message about whether a directory exists on the target machine.Synopsis
This article describes how to create an InstallScript Custom Action that detects and displays a message about whether a directory exists on the target machine.Discussion
Two steps are necessary to add this functionality to the install project:
- Code the InstallScript function
- Create the InstallScript Custom Action
Below are the detailed instructions for performing both these tasks:
Code the InstallScript function
- Open the Install project in the InstallShield IDE under the "Installation Designer" tab.
- In the left pane, go to the Behavior and Logic->InstallScript view.
- In the middle pane, right click on the Files node and select "New Script File" from the popped up menu. This will add a setup.rul file to the project.
- To edit the setup.rul file, click on the setup.rul node. The Script Editor should now be displaying the contents of setup.rul in the right pane.
- Add the following line to the setup.rul file:
export prototype CheckForDirectory(HWND);
- Add the following function to the end of the setup.rul file:
function CheckForDirectory( hMSI )
//Declare string variables
STRING szDirectoryPath, szMessageExists, szMessageDoesNotExist;
BOOL bResult;
begin
//Initalize variables
szDirectoryPath = "C:\\testDirectory\\testSubdirectory"; //Directory path to check
szMessageExists = "The directory exists."; //Message to display if directory exists
szMessageDoesNotExist = "The directory does not exist."; //Message to display if directory does not exist
bResult = FALSE; //Initial return value
szMessageExists = "The directory exists."; //Message to display if directory exists
szMessageDoesNotExist = "The directory does not exist."; //Message to display if directory does not exist
bResult = FALSE; //Initial return value
//Check if the directory path exists
bResult = Is( PATH_EXISTS, szDirectoryPath );
bResult = Is( PATH_EXISTS, szDirectoryPath );
//Display the appropriate message
if ( bResult = TRUE ) then
MessageBox( szMessageExists, INFORMATION );
else
MessageBox( szMessageDoesNotExist, INFORMATION );
endif;
if ( bResult = TRUE ) then
MessageBox( szMessageExists, INFORMATION );
else
MessageBox( szMessageDoesNotExist, INFORMATION );
endif;
end;
Create the InstallScript Custom Action
-
In the left pane, go to the Behavior and Logic->Custom Actions and Sequences view.
-
In the middle pane, right click on the node labeled "Custom Actions" and select "New InstallScript" from the popped up menu.
-
In the right pane, right click on the far right of the "Function Name" row, click on the down arrow control, and select"CheckForDirectory" from the drop down list.
-
Leave the "In-Script Execution" property set to the default, "Immediate Execution"
-
Leave the "Execution Scheduling" property set to the default, "Always Execute".
-
Using the row?s drop down arrow, set "Install Exec Sequence" to "After InstallValidate"
-
To prevent the Custom Action from running during uninstall, set the "Install Exec Condition" to REMOVE<>"ALL"
-
To prevent the Custom Action from also running during a silent installation, modify the condition to (REMOVE<>"ALL") AND (UILevel=5)
Additional Information
For those who prefer less scripting, similar functionality can also be accomplished via the System Search view. Once the desired directory is located, it will write to the property specified. A simple custom action could be written that checks if the property is populated, and display a message box or modal dialog. Additional information on adding a System Search can be found in the HelpNet Library topic Adding a System Search.Was this helpful?
Related Articles
Create a 64-bit Windows Registry Entry via an InstallScript Custom Action 9Number of Views Detect .NET Framework 4.6 And Display A Show Message Dialog Indicating Whether .NET Framework 4.6 Was Detected with Instal… 4Number of Views Access SUPPORTDIR from an InstallScript Custom Action 6Number of Views Writing to the Log File from a Custom Action in an MSI 13Number of Views Delete/Disable a Scheduled Task Using an InstallScript Custom Action 5Number of Views
Revenera Assistant
Online
Hi, I am Reva - Ask me anything.
Updates
No new updates
Chat
Home
Updates
/**/
Thanks for the feedback!
Your feedback has been saved.Rate this response:
1
2
3
4
5
Add Additional feedback ( Optional )
0/240
English
English
Language changed successfully
Something went wrong
Email sent successfully
Something went wrong
Case create successfully
Are you sure you want to cancel
the case creation?
Please select a product to submit the case.
Please select a product version to submit the case.
0/255
Upload Attachment
File Upload
Maximum file
size allowed is 3 MB.
File type
not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Are you sure you want to cancel the case creation?
Case closed successfully
File Upload
Maximum file size allowed is 3 MB.
File type not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
File Upload
Maximum file
size allowed is 3 MB.
File type
not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
© 2026 Flexera Software. All Rights Reserved.
Case id: 00001065
Activity: Status change: 2 hours ago