run exe after msi install, I see the launch checkbox but app does not run

I am using the script from this answer http://stackoverflow.com/a/1681410/22 to insert a launch application checkbox at the end of the MSI installer.

Everything builds ok and I get the launch checkbox just fine, however the application does not launch when the installer is complete.

Not sure if this is the cause but my app does require admin (app.manifest)

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Installer Build Output:

------ Starting pre-build validation for project 'MyAppInstaller' ------ 
------ Pre-build validation for project 'MyAppInstaller' completed ------
------ Build started: Project: MyAppInstaller, Configuration: Release ------
Building file 'C:\path\to\MyAppInstaller.msi'...
Packaging file 'MyApp.exe'...
Packaging file 'Icon.ico'...
Starting post-build events...
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Updating the Control table...
Updating the ControlEvent table...
Updating the CustomAction table...
Updating the Property table...

Done Adding Additional Store

Successfully signed: MyAppInstaller.msi

Edit:

If I right click the setup project in Visual Studio and select “Install”. The app runs when the installer closes.

However, if I just double click the generated MSI. The app will not open after the MSI closes.

I’ve also tried to change the custom action to this, but I still get the same results:

sql = "INSERT INTO `CustomAction` (`Action`, `Type`, `Source`, `Target`) VALUES ('VSDCA_Launch', '226', 'TARGETDIR', '[TARGETDIR]\\MyApp.exe')";

Update:

I ended up using a slightly modified version of “DJ KRAZE” answer. In my Main method I check for a “frominstaller” argument and then just launch the app in a new process and exit. Which then allows the installer to continue normally. Then I add the exe in the “Install” custom action with the “/frominstaller” argument.

if (frominstaller)
{
    Process p = new Process();
    p.StartInfo.FileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
    p.Start();
    Application.Exit();
}
Add Comment
1 Answer(s)

Have you tried these steps as listed in the post from the link that you referenced..?

To run any application after the installation is complete, right-click on your setup project, click on Custom Actions. Then right-click on Commit, Add Custom Action, and choose the file you would like to run. Note that it has to be in your application folder already, which shouldn’t be a problem in your case since you are running your program anyway. Simply choose the output of your project.

Then, click on this added .exe, and change InstallerClass to false. This is crucial because it will look for an installer program otherwise.

You could even pass parameters to your .exe by adding them to the Arguments property

Answered on July 2, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.