Question

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;
    }
}
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top