2

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();
}
Community
  • 1
  • 1
Matt MacLean
  • 19,410
  • 7
  • 50
  • 53

1 Answers1

2

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

MethodMan
  • 18,625
  • 6
  • 34
  • 52
  • 1
    This does not work as expected as the application is launched from the MSI process and the installer will not complete until the app is closed. – Matt MacLean Jan 19 '12 at 22:29
  • is there something or some way you can force close or trick it based on the checkbox – MethodMan Jan 19 '12 at 22:32
  • If I add the exe to the Commit action, the MSI never makes it to the finished screen, just sits on the progress screen until the app exits. – Matt MacLean Jan 19 '12 at 22:36
  • That's strange.. and there are no additional post acticons or custom actions in the MSI project you created..? – MethodMan Jan 19 '12 at 22:38
  • Nothing. Just a plain install project. – Matt MacLean Jan 19 '12 at 22:39
  • What do you have as far as Custom Actions.. I know it's like repeating but I can't tell becasue I am not there to see how your project truly looks or how it's setup.. – MethodMan Jan 19 '12 at 22:43
  • No custom actions other then adding the exe in "Commit". – Matt MacLean Jan 19 '12 at 22:47
  • and what about it being already in your application folder.. that's the .exe I am assuming that you are wanting to launch after the .msi install which means you would have to copy it over to a folder first..then launch the .MSI – MethodMan Jan 19 '12 at 22:50
  • The exe gets installed to the install directory ok (C:\Program Files\MyApp\MyApp.exe). And it does launch if I use the custom "commit" action. But using the commit action hangs the installer until the app exits. – Matt MacLean Jan 19 '12 at 22:51
  • Oh ok I see what you are saying.. so you basically want it to launch and then exit the MSI.. does it minimize the MSI installer.. I wonder if that's normal behavior.. I will also look back at MSDN site for this.. I have done MSI installs before never had this problem let me dig around – MethodMan Jan 19 '12 at 22:53
  • 1
    Got it working, not ideal but it works :). See post for update. – Matt MacLean Jan 19 '12 at 23:04