Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart my application if Windows Update forces a reboot?

At the office, when I leave for the night I very rarely log off or reboot. I simply lock my workstation and go home, leaving all my development tools exactly how I left them.

If Windows-Update rolls through and reboots my machine in the middle of the night I'm only slightly peeved because when I log back in the next morning, any MS Office application, or Visual Studio instance I had running will have already automatically restarted, opening whatever file(s)/projects/solutions I may have been working on.

My question is: How can I make my Windows Forms applications (C#) do this? Is there some way for my application to "register" that it wants to be restarted if the system automatically reboots?

like image 397
Yoopergeek Avatar asked Jul 02 '09 21:07

Yoopergeek


People also ask

How do I stop automatic restart after Windows Update?

To do so through Group Policy, go to Computer Configuration\Administrative Templates\Windows Components\Windows Update and select Turn off auto-restart notifications for update installations.

How do I force Windows Update to restart?

Select Start > Settings > Windows Update . Select Schedule the restart and choose a time that's convenient for you.

How do I reboot after update?

Here's how. Click on Settings > Update & Security > Windows Update. Scroll down and click on Advanced Options. Toggle on Restart the device as soon as possible when a restart is required to install an update.


1 Answers

I think the RegisterApplicationRestart Win32 API function might be what you're after, it's part of the Restart Manager API.

like image 85
Rob Avatar answered Sep 19 '22 11:09

Rob