Option to launch app after close

Apr 8, 2016 at 3:54 PM
Edited Apr 8, 2016 at 3:55 PM
I want to know how to add an optional checkbox into the exitDialog. The idea is to allow the user to choose running the app after closing the setup.
What i want to reproduce is this How To: Run the Installed Application After Setup in a WIX# way

Thank you.
Coordinator
Apr 10, 2016 at 3:57 AM
The simplest approach is to avoid inconvenience of the raw WiX and use Wix# ManagedSetup.
void finish_Click(object sender, System.EventArgs e)
{
    if (runAfter.Checked)
        try
        {
            Process.Start(Path.Combine(MsiRuntime.InstallDir, "myproduct.exe");
        }
        catch { }
    Shell.Exit();
}
Apr 11, 2016 at 10:09 AM
Edited Apr 11, 2016 at 10:41 AM
Thank you for your reply.
Meanwhile i've found a workarround without custom dialog.

First i added a custom project property:
project.AddProperty(new Property(new Id("WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT"),
                    "WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT", "Launch My Product"));
then declared an InstalledFileAction
project.Actions = new WixSharp.Action[] {
    new InstalledFileAction("myproduct.exe", "", 
        Return.asyncNoWait, When.Before, Step.InstallFinalize, Condition.NOT_Installed
    ){ Id = "LaunchAfterClose" }
}; 
changed the dialog sequence
project.CustomUI = new DialogSequence()
    .On("ExitDialog", Buttons.Finish, 
        new ExecuteCustomAction("LaunchAfterClose", "WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed")
        );
As far as I tested, it seems to work.
Say something if you have any suggestions for improvement.

Thank you, and great project by the way!
Coordinator
Apr 11, 2016 at 1:38 PM
Edited Apr 11, 2016 at 1:41 PM
Great. There is nothing wrong with this approach at all. I do prefer Managed Setup but not because it works better :)

As a side note, I am impressed that you are using native WiX dialog customization. I thought this development direction had no interest among developers.

You can also replace literal "ExitDialog" with enun:
project.CustomUI = 
   new DialogSequence()
        .On(NativeDialogs.ExitDialog, Buttons.Finish, 
            new ExecuteCustomAction("LaunchAfterClose", 
                                     "WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed")
...