Understanding RegisterApplicationRestart with MSIX Store Updates

When building full-trust desktop applications (such as Flutter Windows apps packaged as MSIX) for the Microsoft Store, managing self-updates seamlessly is critical. A common architecture involves using WinRT StoreContext to check, download, and install updates asynchronously, followed by a call to RegisterApplicationRestart and ExitProcess(0) to apply the update and relaunch.

However, many developers notice that calling ExitProcess(0) after a store update fails to relaunch the application. Understanding how Windows Restart Manager and MSIX servicing interact explains why this happens and how to implement the supported update sequence.

Why ExitProcess(0) Prevents Application Relaunch

Calling ExitProcess(0) directly suppresses automatic relaunch mechanisms. RegisterApplicationRestart relies on Windows Application Recovery and Restart (ARR) and the Windows Restart Manager (RM).

  • Explicit Termination vs. Restart Manager: A direct call to ExitProcess(0) signals to the OS that the application is deliberately shutting itself down. Windows treats this as a clean, user- or app-initiated termination and will not trigger a relaunch.
  • Flag Misconfiguration: Passing RESTART_NO_CRASH | RESTART_NO_HANG explicitly disables restarts caused by crashes and hangs. This leaves installer-initiated restarts or system reboot restarts as the only valid triggers. Because ExitProcess(0) bypasses the Restart Manager lifecycle, no restart occurs.

Is Code Execution Guaranteed After Store Updates?

When calling RequestDownloadAndInstallStorePackageUpdatesAsync, execution after the operation returns with OverallState::Completed is not guaranteed.

During package deployment, the Windows Store deployment engine (App Installer / Deployment Web Service) services the MSIX package. As part of this servicing, the deployment pipeline may terminate the running process directly before or immediately after package replacement. Relying on post-update execution logic—such as manually invoking clean-up tasks or calling ExitProcess—creates race conditions.

The Supported Update & Restart Sequence

To ensure robust self-updating in MSIX desktop apps, follow the documented Windows lifecycle workflow:

  1. Register Early: Call RegisterApplicationRestart during application startup (or before triggering the update request), rather than right before terminating the process.
  2. Listen for System Messages: Handle WM_QUERYENDSESSION and WM_ENDSESSION in your window procedure to save state or flush pending logs.
  3. Trigger Store Update: Invoke RequestDownloadAndInstallStorePackageUpdatesAsync and allow the Windows Store deployment pipeline to manage process closure.
  4. Do Not Call ExitProcess: Let the deployment engine automatically terminate and relaunch the application once the servicing operation completes.

Correct C++ Implementation Example