[wix-users] Burn with mba, force reboot in middle of chain and handle restart.
Phill Hogland
phill.hogland at rimage.com
Sat Sep 12 15:47:50 PDT 2015
I appreciate the helpful information from Jeremy (and the older threads from Sean and Rob), but I am still missing something as it relates to signaling a need for a reboot, from my CA, to the MSI, to the Bundle. When the error scenario is detected in my CA, the code is returning hr = S_OK. I call WcaDeferredActionRequiresReboot();, but in the mba's ExecutePackageComplete the e.Restart for that PackageId is never ApplyRestart.RestartRequired, rather it is always ApplyRestart.None.
In my CA I have code like this:
if (0x80070BC2 == hr) { //success, reboot is needed, so changes may not be effective until after the reboot
WcaLog(LOGMSG_STANDARD, "Return code, %#x, indicates a reboot is needed. The installed features may not be available until after the next reboot, but this setup will proceed.\n", hr);
WcaDeferredActionRequiresReboot();
hr = S_OK; // Also tried to return hr = HRESULT_FROM_WIN32(ERROR_SUCCESS_REBOOT_REQUIRED); but results in the MSI failing.
}
In the MSI log when this error happens I see the log messages and the CA return code of zero.
In the mba I have ExecutePackageComplete code like this
private void ExecutePackageComplete(object sender, ExecutePackageCompleteEventArgs e)
{
// For the EnableWinFeature packages (named EnableWinFeature_x86 and EnableWinFeature_x64) , we may need to do a forced reboot. Process whether forced reboot is allowed in ApplyComplete
mba.Engine.Log(LogLevel.Standard, string.Format("InstallationViewModel::ExecutePackageComplete: PackageId: {0}, Restart: {1}, Status: {2}, Result: {3}", e.PackageId, e.Restart, e.Status, e.Result));
if (true == e.PackageId.Contains(@"EnableWinFeature ") && ApplyRestart.RestartRequired == e.Restart)
{
e.Result = Result.Restart;
}
}
However the log message shows that even when the error scenario is logged by the CA, the ExecutePackageComplete always has e.Restart set to "None".
I'm using Wix 3.10.0.2103. I had expected that calling WcaDeferredActionRequiresReboot(); in the CA would cause e.Restart to be set to ApplyRestart.RestartRequired.
What am I missing? How do I signal the bundle that a Restart is required from an MSI's CA?
(I should also add that I tried to return 3010 from the CA which causes the MSI to fail. The only piece of code that I found which uses WcaDeferredActionRequiresReboot(); in the wix source has a CA return value of s_OK, so that is why I have focused on that approach.)
Thanks for any assistance!
Phill
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Jeremy Drake
Sent: Friday, September 11, 2015 11:30 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Burn with mba, force reboot in middle of chain and handle restart.
> Reboot by setting e.Result to Result.Reboot.
Oops, that was supposed to be Result.Restart.
On Fri, 11 Sep 2015, Jeremy Drake wrote:
>> What I am missing is what should I do in the mba to detect that the
>> CA indicated that a reboot is necessary and force the reboot.
>> (Unfortunately I have a later third-party package for which the
>> setup will error out if the error in the above CA is allowed to
>> continue without doing the reboot
>> immediately.)
>
> on ExecutePackageComplete, e.Restart is ApplyRestart.RestartRequired.
> If the package in question (e.PackageId) is the package that you need
> to do this for, and e.Restart is ApplyRestart.RestartRequired, set
> e.Result = Result.Restart. Then, on ApplyComplete, use e.Restart,
> BootstrapperApplication.Command.Restart, and
> BootstrapperApplication.Command.Display to decide to prompt for
> reboot, automatically reboot, or not reboot. Reboot by setting
> e.Result to Result.Reboot.
>
>
> On Fri, 11 Sep 2015, Phill Hogland wrote:
>
>> My mba driven package chain has a package which includes a CA in
>> which I call a system tool to do CBS servicing. That tool may
>> return 0x80070bc2
>>
>> if (0x80070BC2 == hr) { //success, reboot is needed, so changes may
>> not be effective until after the reboot WcaLog(LOGMSG_STANDARD,
>> "Return code, %d, indicates a reboot is needed.
>> The installed features may not be available until after the next
>> reboot, but this setup will proceed.\n", hr);
>> WcaDeferredActionRequiresReboot();
>> hr = S_OK;
>> }
>>
>> I then found Sean's helpful advice on implementing the mba code to
>> handle the restart and I implemented the Startup and PlanPackageBegin changes.
>> What I am missing is what should I do in the mba to detect that the
>> CA indicated that a reboot is necessary and force the reboot.
>> (Unfortunately I have a later third-party package for which the
>> setup will error out if the error in the above CA is allowed to
>> continue without doing the reboot
>> immediately.)
>>
>> I saw the source for WIXAPI WcaDidDeferredActionRequireReboot() but
>> am not sure where I would call this (or equivalent) from my C# mba.
>>
>> And then I also need to handle the situation where a reboot is not
>> allowed as this bundle might be part of a silent script, but that is
>> a separate issue.
>>
>>
>> Thanks for any advice.
>>
>>
>> ____________________________________________________________________
>> WiX Toolset Users Mailing List provided by FireGiant
>> http://www.firegiant.com/
>>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
>
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list