Can't launch application after install

Apr 6, 2016 at 9:06 PM
Hi, I'm working with Wix# and having trouble getting the installer to launch the executable at the end of the install. I've tried multiple approaches, and I feel like I must be missing something.

I've tried:
  1. A managed action that uses the INSTALL_DIR and Process.Start. The managed action runs before the files are copied. This is basically what's described in the RunAppAtTheEnd sample. It's just too early in the process.
var project = new Project("Castle Lockdown",
                new Dir(@"%LocalAppDataFolder%\Castle Worldwide\Lockdown", new Files(@"..\Dist\*.*")), new ManagedAction("LaunchProduct"));

[CustomAction]
        public static ActionResult LaunchProduct(Session session)
        {

            System.Diagnostics.Process.Start(session["INSTALLDIR"] + @"Castle.Lockdown.Browser.exe");

            return ActionResult.Success;
        }
  1. InstalledFileAction. This just appears to do nothing. Nothing is launched, but there are no errors either. I'm using:
project.AddAction(new InstalledFileAction("Castle.Lockdown.Browser.exe", "", Return.asyncNoWait, When.After,
                Step.InstallFinalize, Condition.Always));
Neither of these seem to work at all, surely I've just made a strange assumption somewhere. Any help would be very much appreciated.

Thanks!
Apr 7, 2016 at 12:20 AM
Edited Apr 7, 2016 at 12:20 AM
Ok, so it turns out it has nothing to do with Wix#. For whatever reason, launching this WPF app using Process.Start from anywhere doesn't work if you don't use the ProcessStartInfo class to initialize it with the correct working directory.
Apr 7, 2016 at 1:35 AM
Ok. Great.

> doesn't work if you don't use the ProcessStartInfo
I have never experienced anything like that. Really strange.

> but there are no errors either
It's understandable as Process.Start did not fail but the new process just exited.

Just wanted to say, you can dramatically improve your troubleshooting power if you use some other features of Wix#: setup events, Debugging and logging:
var project = new ManagedProject("ManagedSetup", ...
project.AfterInstall += project_AfterInstall;
...
static void project_AfterInstall(SetupEventArgs e) //runs elevated
{
    Debug.Assert(false);
    Process.Start(Path.Combine(e.InstallDir, "Castle.Lockdown.Browser.exe"));    
}