Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I handle ManagedBootstrapperApplicationHost & reboot / restart in WiX installer?

I am using WiX Burn to install per-requisites of our project, and I have used ManagedBootstrapperApplicationHost to have a custom UI. I am checking for the Windows Installer version and installing it as a prerequisite, but it requires a restart.

How can I handle a restart in code?

I tried checking it in the following code but the e.status value in case of a restart is also 0.

Code

private void PlanComplete(object sender, PlanCompleteEventArgs e)
{
    logger.LogInfoMessage("-------------->>  "+ e.Status.ToString());
    if (Hresult.Succeeded(e.Status))
    {
        this.root.PreApplyState = this.root.State;
        this.root.State = InstallationState.Applying;
        WixBA.Model.Engine.Apply(this.root.ViewWindowHandle);
    }
    else
    {
        this.root.State = InstallationState.Failed;
    }
}
like image 556
Gaurav Avatar asked Dec 22 '25 17:12

Gaurav


1 Answers

The engine will return if a restart is required in the ApplyComplete() callback to your bootstrapper application. You can either decide at that moment to accept the restart and return Result.Restart from the ApplyComplete() callback.

Alternatively, you may want to prompt the user on a finish dialog or something to give them an option to accept the restart or not. In that case, you can return Result.Restart from the Shutdown() callback and the engine will do a restart after your bootstrapper application exits.

I tend to do use the second option most often in my bootstrapper applications.

like image 51
Rob Mensching Avatar answered Dec 24 '25 10:12

Rob Mensching



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!