4

I've got a WiX deferred custom action that conditionally modifies some registry keys. For the changes to take effect, a reboot is required. I'd like the user to get the standard dialog box that prompts them to reboot after the installation completes.

How can I schedule a reboot from a deferred custom action?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Cocowalla
  • 13,822
  • 6
  • 66
  • 112
  • [Some pointers on conditioning ScheduleReboot so it doesn't trigger an undesired reboot prompt in the wrong installation modes](https://stackoverflow.com/questions/48840273/reboot-on-install-dont-reboot-on-uninstall). – Stein Åsmul Apr 03 '18 at 21:33

1 Answers1

4

Why do you have a custom action doing something that MSI/WiX knows how to do natively?

A cleaner approach would be to have registry values associated with a component that has the needed condition. Then you can have a simple custom action trigged by that same condition call MsiSetMode with the MSIRUNMODE_REBOOTATEND argument. If you are using C#/DTF that's session.SetMode(InstallRunMode.RebootAtEnd).

This way if the install is aborted, canceled, failed it can roll back the registry changes.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • 1
    I do so much other *stuff* in the custom action I never even thought about just using WiX to do this! Inspired by your answer, I now simply have a conditional `ScheduleReboot` element in `InstallExecuteSequence` – Cocowalla Dec 10 '14 at 15:21
  • 1
    Bravo on the ScheduleReboot action. That's even better. Always try to eliminate custom actions wherever possible. It results in a much better installer. – Christopher Painter Dec 10 '14 at 15:30