I am using the script from this answer https://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();
}