Summary
It is necessary to create a new custom action in order to set the working directory when launching an executable at the end of an installation.
Synopsis
By default, the functionality in InstallShield for launching the application at the end of the installation does not set a working directory. It is necessary to create a new custom action in order to set the working directory for the launched executable.
Discussion
The following steps can be followed in order to configure the installation to conditionally launch an executable (based on a check box).
Windows Installer Projects
-
Create a new Basic MSI project
-
In the Project Assistant tab, select the Application Files view and add an .exe file and any necessary files.
-
Select the Installation Interview view and select "Yes" to "Do you want to give users the option to launch your application when the installation completes?" This will automatically add an exe custom action to launch the specified application based on a checkbox.
-
By default, the LAUNCHPROGRAM property tied to the condition of the custom action has no value, and so the check box appears deselected by default at run time. To specify that the check box should be initially selected, you can add LAUNCHPROGRAM to the Property Manager view with value 1.
-
In the Releases view, under the Setup.exe tab for your release, set the Required Execution Level setting to Administrator.
- Save, build and test.
InstallScript Projects
For an InstallScript project, you add the option to launch the application by modifying the OnFirstUIAfter event handler. By default, the OnFirstUIAfter event handler contains an if statement that checks whether a reboot is necessary and whether you included Update Service support, and displays the appropriate completion dialog box. The possible completion dialog boxes are SdFinishReboot, SdFinishUpdateEx, and SdFinish. In most cases, SdFinish is the dialog box you will want to modify.
In the default implementation of OnFirstUIAfter, the branch of the if statement that displays SdFinish appears simply as follows:
SdFinish(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bvOpt1, bvOpt2);
To enable the check box with appropriate text, and launch your application if the user selects the check box, you can modify the branch of the if statement to appear as follows:
bvOpt1 = TRUE; // enable check box
szOpt1 = "Launch %p"; // %p expands to product name
SdFinish(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bvOpt1, bvOpt2);
if (bvOpt1) then
LaunchApp(TARGETDIR ^ "sample.exe", "");
endif;
(In practice, you should use a string-table entry instead of a hard-coded string for szOpt1, to ease localization of your installation project.)
At run time, the dialog box appears as follows.
Additional Information
The Project Assistant is used in this example to quickly and easily create the checkbox required for a conditional launch. If a developer is comfortable with modifying Windows Installer dialogs, the Project assistant steps can be skipped and the dialog edited manually.
For more information on custom actions see the HelpNet article Custom Action Wizard .
Related Articles
Launch Application When Installation Completes 5Number of Views Launching an HTML Page During Installation 4Number of Views Add/Remove Programs Hangs When Launching an Application During Uninstall 6Number of Views Launch Another Installation or Uninstallation from within an Installation 5Number of Views How Do I Launch My Application at the End of the Setup? 4Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add additional feedback (optional)
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
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. | |
Case id: 00001065
Activity: Status change: 2 hours ago