Detect whether a Windows reboot was due to Windows updates Detect whether a Windows reboot was due to Windows updates windows windows

Detect whether a Windows reboot was due to Windows updates


See Application Restart:

An application can use Application Recovery and Restart (ARR) to save data and state information before the application exits due to an unhandled exception or when the application stops responding

and:

or if the computer needs to restart as the result of an update.

The applications aren't detecting the restart reason after the fact - they've been architected to use this API. There isn't (so far as I'm aware) a managed API for this.


A couple of clicks away is Saving data and application state when application is being closed due to a software update. Again, no managed API.


Normally when Windows Reboots, it performs a restart by using shutdown.exe and the /g flag which saves the state of all registered running programs before restart. What you want to do is to Register your application for restart. There is a good sample with documentation for this by MSDN. It is available in C# and C++.