Force ScheduleReboot

Nov 15, 2016 at 2:17 PM
Is there a way to add the ScheduleReboot action to a ManagedProject?
I need to schedule rebooting at the end of the install regardless of if the installer determines it is required or not (due to some third party dependencies).

I did try the below, which works, however the reboot is quite abrupt, and currently I dont have a dialog prompting or warning about the reboot.
new Property("REBOOT", "Force") { IsDeferred = true } 
I'm using the ManagedUI below
project.ManagedUI = new ManagedUI();
I also tried the "reboot" sample, however the dialog box and the method of rebooting isn't the greatest.

Nov 17, 2016 at 11:21 PM
You can control rebooting via dedicated WiX/Wix# project properties ScheduleReboot, ForceReboot and RebootSupressing.
project.ScheduleReboot = new ScheduleReboot();
The code above will does the trick and I see it pops the standard prompt dialog.
Nov 18, 2016 at 6:32 PM
I knew it would be easier than I thought, I wasn't finding ScheduleReboot.

However, I'm not getting the reboot dialog. The ExitDialog is shown, then once Finish is pressed the computer immediately reboots.

It looks like it shows up correctly in the Installer.g.wxs file....
      <Custom Action="Set_Action1_RunRegisterDriver_Props" After="InstallInitialize" />
      <Custom Action="Action1_RunRegisterDriver" After="InstallFiles"> (NOT (REMOVE="ALL")) </Custom>
      <Custom Action="WixSharp_InitRuntime_Action" Before="AppSearch"> (1) </Custom>
      <Custom Action="Set_CancelRequestHandler_Props" After="InstallInitialize" />
      <Custom Action="CancelRequestHandler" Before="InstallFinalize"> (NOT (REMOVE="ALL")) </Custom>
      <Custom Action="Set_ARPINSTALLLOCATION" After="CancelRequestHandler"> (NOT Installed) </Custom>
      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>

      <RemoveExistingProducts After="InstallFinalize" />

      <ScheduleReboot After="InstallExecute" />

      <Custom Action="Set_INSTALLDIR_AbsolutePath" Before="AppSearch">(NOT Installed) AND (UILevel &lt; 5) AND (INSTALLDIR = ABSOLUTEPATH)</Custom>
The log shows what I imagine the prompt is....
Info: Action ended 13:11:30: INSTALL. Return value 1.
User: You must restart your system for the configuration changes made to My Sweet Program to take effect. Click Yes to restart now or No if you plan to manually restart later.
but no actual dialog appears.
Nov 19, 2016 at 10:56 AM
Sorry, I completely puzzled by this. In my simple test (slightly modified InstallFiles) it did pop the prompt.
I can only assume that the reboot is indeed is scheduled but the UI prompt is suppressed because of the EmbeddedUI. It is actually plausible as MSI completely delegates the UI sequence to the user defined routine - ManagedUI.

If it is the case then what you need to do is to pop up your own UI prompt (some simple WinForm based dialog) from ExitDialog or better yet from AfterInstall event.
Nov 21, 2016 at 3:38 AM
It appears to work fine (displays the "do you want to restart now or later" dialog) until I add the below code...
        project.ManagedUI = new ManagedUI();
        project.ManagedUI = ManagedUI.Default;
Looks like once the ManagedUI sequence modifies it to no longer show the prompt.

Thanks for the help. I'll have to take your recommendation to build my own "do you want to reboot" dialog.