{"id":92261,"date":"2015-12-03T07:00:00","date_gmt":"2015-12-03T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20151203-00\/?p=92261\/"},"modified":"2019-03-13T12:22:29","modified_gmt":"2019-03-13T19:22:29","slug":"20151203-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20151203-00\/?p=92261","title":{"rendered":"A question about how to detect whether Windows Update needs the system to be restarted turns out to be the wrong question"},"content":{"rendered":"<p><!-- Adrian Bliss (adrianbl) win32prg 7\/5\/2012 \"Reboot flags\"; Mark Phaedrus provided most of the information here --><\/p>\n<p>A customer wanted to know whether there was a way to detect that Windows Update has recently installed an update that requires a reboot. They explained that their computers are running dedicated software, and the customers are not technically-savvy, so they want to display the &#8220;You need to reboot&#8221; message more prominently, and let the user choose the best time to reboot. &#8220;We have been checking a variety of registry keys, and we have found that the set of keys to check is quite extensive and varies depending on the nature of the update that was installed.&#8221; <\/p>\n<p>There is a fairly straightforward way to check <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2015\/09\/21\/10642727.aspx\">whether Windows Update is waiting for the system to reboot<\/a>, but we asked for more information about the customer&#8217;s scenario. Fortunately, the customer was willing to share. <\/p>\n<blockquote CLASS=\"q\"><p>These computers are in a hospital running critical medical software. The software runs 24\/7 and must not reboot without user consent. <\/p><\/blockquote>\n<p>If these are critical machines, then asking whether Windows Update is requesting a reboot is the wrong question. By the time you get the answer &#8220;Yes&#8221;, you are already in trouble: If you reboot the computer as soon as a reboot is required, you interrupt the machine&#8217;s critical functioning. If you postpone the reboot, then you leave the computer in a nonstandard configuration wherein an update is partially-installed, and that nonstandard configuration may compromise the machine&#8217;s critical function. <\/p>\n<p>In this specific case, the idea would be to change the design from &#8220;Install the update, and then postpone the reboot until a convenient time&#8221; to &#8220;Wait for a convenient time, then install the update and reboot immediately.&#8221; Here&#8217;s a sketch of how it could work. (Note: This is a sketch, not a fully-analyzed scenario. Do not implement this design on your critical medical systems before independently validating its efficacy to your satisfaction. In fact, as a general rule, you should not use blog posts as the sole basis for software design decisions for critical medical systems.) <\/p>\n<ul>\n<li>Set Automatic Updates so it does not install updates     immediately. Either disable it, or set it to     download updates without installing them. \n<li>Ensure that users do not have permission to alter these settings     or to initiate the installation of updates independently. \n<li>Periodically check whether there are new updates available.     The     <a HREF=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa387102(v=vs.85).aspx\">    Searching, Downloading, and Installing Updates<\/a>     script on MSDN is an example of how you can use the     Windows Update Agent API to answer questions like this. \n<li>If there are updates available that do not require a reboot,     you may choose to install them without interrupting service.     You can use the     <a HREF=\"http:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.updateservices.administration.installationbehavior.rebootbehavior%28v=vs.85%29.aspx\">    <code>Installation&shy;Behavior.Reboot&shy;Behavior<\/code><\/a>     property     to determine whether a particular update     guarantees that it can be installed     without a reboot. \n<li>If there are updates available that may require a reboot,     inform the user that the computer will be unavailable while     the updates are installed and let the user choose when to install     those updates. \n<li>When installing the updates, display a message indicating that     the computer is unavailable. \n<li>When installation is complete, reboot immediately. <\/ul>\n<p>The important things are that (1)&nbsp;you treat the installation of the update and the reboot as a unit, and (2)&nbsp;you don&#8217;t start the install+reboot process until the user confirms that they are okay with the system being temporarily unavailable. <\/p>\n<p>Thanks to my colleague Mark Phaedrus for providing the raw materials from which this article was constructed. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>For critical availability, don&#8217;t install it until you are ready to reboot.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-92261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>For critical availability, don&#8217;t install it until you are ready to reboot.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/92261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=92261"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/92261\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=92261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=92261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=92261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}