<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hans Ravnaas' Manageability Blog</title><link>http://blogs.msdn.com/hansr/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How to detect if a reboot is needed after installing a patch</title><link>http://blogs.msdn.com/hansr/archive/2006/02/17/PatchReboot.aspx</link><pubDate>Sat, 18 Feb 2006 02:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:534498</guid><dc:creator>hravnaas</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/hansr/comments/534498.aspx</comments><wfw:commentRss>http://blogs.msdn.com/hansr/commentrss.aspx?PostID=534498</wfw:commentRss><description>&lt;P&gt;If you use &lt;A class=KeywordHighlight name=#h3&gt;ITMU&lt;/A&gt; (SMS 2003 Inventory Tool for Microsoft Updates) or MBSA 2.0 to scan &lt;BR&gt;machines for patch status, a patch may be reported as installed even though a &lt;BR&gt;reboot is needed in order complete the installation. Example scenario:&lt;BR&gt;&lt;BR&gt;- You install patch M05-051 (KB 902400) by manually downloading the patch &lt;BR&gt;installation EXE and then running the EXE.&lt;BR&gt;&lt;BR&gt;- After the installation is done, you do not reboot the machine even though the &lt;BR&gt;installation wizard states that it's needed.&lt;BR&gt;&lt;BR&gt;- You scan the client using &lt;A class=KeywordHighlight name=#h4&gt;ITMU&lt;/A&gt; (scanwrapper.exe) or MBSA 2.0 (mbsacli.exe). The &lt;BR&gt;patch is reported as installed by both &lt;A class=KeywordHighlight name=#h5&gt;ITMU&lt;/A&gt; and MBSA. However, MBSA flags that a &lt;BR&gt;reboot is needed by some software update/patch as part of its general vulnerability &lt;BR&gt;scan, not its software updates scan. Note that in this scenario, MBSA 1.2.x would &lt;BR&gt;report the patch as applicable.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;This behavior is by design. Both &lt;A class=KeywordHighlight name=#h7&gt;ITMU&lt;/A&gt; and MBSA 2.0 use the Windows Update Agent &lt;BR&gt;(WUA) as their scan agent, hence the identical results. (WUA logs to &lt;BR&gt;%systemroot%\WindowsUpdate.log). In order for &lt;A class=KeywordHighlight name=#h8&gt;ITMU&lt;/A&gt; to accurately report software &lt;BR&gt;update status, the software updates/patches need to be installed through &lt;A class=KeywordHighlight name=#h9&gt;ITMU&lt;/A&gt; or &lt;BR&gt;Microsoft Update. The reason for this is that when a patch is manually installed, a &lt;BR&gt;registry key/value that &lt;A class=KeywordHighlight name=#h10&gt;ITMU&lt;/A&gt; uses to detect needed reboots is not set. This is set &lt;BR&gt;by WUA which is not utilized when the patch is manually installed. Here's how &lt;A class=KeywordHighlight name=#h11&gt;ITMU&lt;/A&gt; &lt;BR&gt;detects a pending reboot:&lt;BR&gt;&lt;BR&gt;1. When a patch is installed by WUA, either via &lt;A class=KeywordHighlight name=#h12&gt;ITMU&lt;/A&gt; or Microsoft Update, if the &lt;BR&gt;patch installation returns exit code 3010, WUA creates the volatile registry key &lt;BR&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto &lt;BR&gt;Update\RebootRequired. It then adds a DWORD value for each update ID that requires &lt;BR&gt;a reboot, for example:&lt;BR&gt;&lt;BR&gt;"9306cdfc-c4a1-4a22-9996-848cb67eddc3"=1&lt;BR&gt;&lt;BR&gt;2. When &lt;A class=KeywordHighlight name=#h13&gt;ITMU&lt;/A&gt; next performs a scan via smswushandler.exe which invokes a WUA scan, &lt;BR&gt;the following takes place:&lt;BR&gt;&lt;BR&gt;a) WUA will scan for missing updates according to their detection rules. If a patch doesn't pass its detection rules, WUA reports that a reboot is pending. &lt;BR&gt;&lt;BR&gt;b) If a patch is reported as installed by WUA, &lt;A class=KeywordHighlight name=#h14&gt;ITMU&lt;/A&gt; (smswushandler.exe) checks to &lt;BR&gt;see if any patches are listed under &lt;BR&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired. If so, those are flagged as applicable. As mentioned &lt;BR&gt;earlier, this key will be missing if a patch was manually installed. Note that the &lt;BR&gt;RebootRequired key is automatically deleted when the machine reboots as it's &lt;BR&gt;volatile (only held in memory). It's possible to manually create the RebootRequired &lt;BR&gt;key and its values to force &lt;A class=KeywordHighlight name=#h15&gt;ITMU&lt;/A&gt; to detect a pending reboot. The Win32 API &lt;BR&gt;RegCreateKeyEx could be used with the REG_OPTION_VOLATILE flag set for dwOptions to create the RebootRequired key.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;So without SMS and &lt;A class=KeywordHighlight name=#h16&gt;ITMU&lt;/A&gt; in the picture, why does MBSA 1.2.x report the patch as &lt;BR&gt;applicable while &lt;A class=KeywordHighlight name=#h17&gt;ITMU&lt;/A&gt; and MBSA 2.0 (actually WUA) report it as installed when the &lt;BR&gt;detection rules really are the same? The reason is that when WUA comes across a &lt;BR&gt;file version or file CRC detection rule, in addition to the file's original &lt;BR&gt;location, for example system32, WUA also checks the files that the &lt;BR&gt;PendingFileRenameOperations value under &lt;BR&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager points to. &lt;BR&gt;&lt;BR&gt;Example:&lt;BR&gt;&lt;BR&gt;The detection rule for a patch states that file system32\clbcatq.dll should be &lt;BR&gt;version 10.&lt;BR&gt;The current version of the file in system32 is 9.&lt;BR&gt;WUA performs a scan and finds that the file is in compliance.&lt;BR&gt;PendingFileRenameOperations&amp;nbsp; has the following two entries:&lt;BR&gt;\??\C:\WINDOWS\system32\SET31.tmp&lt;BR&gt;!\??\C:\WINDOWS\system32\clbcatq.dll&lt;BR&gt;During a scan, WUA will actually check the file version of system32\SET31.tmp which &lt;BR&gt;is 10.&lt;BR&gt;SET31.tmp will be renamed to clbcatq.dll when the machine restarts.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;Besides the above two registry values under "Session Manager" and "RebootRequired", &lt;BR&gt;there is a third one that can be used to detect a pending reboot. &lt;A class=KeywordHighlight name=#h18&gt;ITMU&lt;/A&gt; can't use &lt;BR&gt;this though as &lt;A class=KeywordHighlight name=#h19&gt;ITMU&lt;/A&gt; reports compliance on a per patch basis, not per machine. &lt;BR&gt;However, MBSA 2.0 makes use of this new registry key that was introduced with &lt;BR&gt;version 6.1.22.0 and later of update.exe. The key is &lt;BR&gt;HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile and the value is called flags. &lt;BR&gt;See http://support.microsoft.com/default.aspx?kbid=832475 for details on this &lt;BR&gt;value. Basically, if you have a 1 or 2 in the flags value, a reboot is pending. &lt;BR&gt;MBSA 1.2.x or &lt;A class=KeywordHighlight name=#h20&gt;ITMU&lt;/A&gt; does not check this key/value. A possible workaround to detect &lt;BR&gt;pending reboots when a patch was not installed via WUA, is to for example send out &lt;BR&gt;a vbscript or update sms_def.mof to check for the presence of this key/value.&lt;BR&gt;&lt;BR&gt;To use MBSA 2.0 to detect a missing reboot, run mbsacli /n Password+OS+SQL+IIS /nai &lt;BR&gt;/nm&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;To query WUA for outstanding reboots, use the script at &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wua_sdk/wua/using_wua_to_scan_for_updates_offline.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wua_sdk/wua/using_wua_to_scan_for_updates_offline.asp&lt;/A&gt;&amp;nbsp;and replace "IsInstalled=0" with "RebootRequired=1".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=534498" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/hansr/archive/tags/SMS/default.aspx">SMS</category></item></channel></rss>