Batch/Powershell: How to check Pending Computer Restart after Installing Windows Update

Some windows updates require a system restart after installation because it needs to change some system files which are currently used by running processes, or changes in registry. You’ll be prompted with the yellow icon shield like in fig-1.

Fig-1: Pending Restart after windows update install
 

Windows created a registry subkey RebootRequired under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update to detect this pending state.
So, for easy job, I wrote the little batch script (for windows XP & Server 2003) and powershell script (for Windows Vista & Server 2008 or later) to detect this key. Use either of the script.
Fig-2 & Fig-3 shows running the batch script on computer which needs pending restart & which doesn’t.

Fig-2: This computer is pending restart
Fig-3: This computer doesn’t need reboot

 
You can download my script from github.

The Fig-4 & Fig-5 shows the script written in powershell to detect pending reboot.

Fig-4: This computer need pending reboot
Fig-5: This computer does not need pending reboot

One thought on “Batch/Powershell: How to check Pending Computer Restart after Installing Windows Update”

Leave a Reply

Your email address will not be published. Required fields are marked *