Detecting pending reboots (on Windows 8)

Apr 1, 2013 at 7:39 PM
Hi Matt

Thank you for this brilliant tool!

Just wanted to mention a small problem I ran into, when testing BoxStarter on a (mostly) vanilla Windows 8 Pro laptop using an install script fairly not to far removed from the example on the project home page.

A previous install or Windows update had left a pending reboot flag but the Test-PendingReboot method was returning false, and the VS 2012 install subsequently failed. I saw you used a script from Brian Wilhite on TechNet Gallery that leverages WMI to query for reboot status as the basis for the method, for some reason it was not detecting the appropriate status.

What I did to get around this problem was to switch to using a Powershell module from Michal Gajda that I also found on TechNet, that uses the SystemInfo COM API to get the status. The check for pending reboots then became:
Import-Module PsWindowsUpdate
if(Get-WURebootStatus -Silent){Invoke-Reboot}
The PsWindowsUpdate module is actually very useful for manipulating Windows Update and I have created a Chocolatey package to install it to use with BoxStarter among other things.

I haven't had the opportunity to reproduce this problem on other Windows machines but I wanted to mention this if you or others would came across the same issue.

Apr 1, 2013 at 10:52 PM
Thanks a bunch for the feed back. Will definitely look into this!