ISystemInformation::RebootRequired: Somebody asked for some sample code to call ISystemInformation::RebootRequired mentioned in Arnson's answer.
Here is one blurb - not exactly great, but maybe give it a try:
Set autoupdate = CreateObject("Microsoft.Update.AutoUpdate")
autoupdate.Pause()
MsgBox Err.Number & " " & Err.Description
Set sys = CreateObject("Microsoft.Update.SystemInfo")
MsgBox sys.RebootRequired
' autoupdate.Resume() ' Enable to resume AutoUpdate
Set sys = Nothing
Set autoupdate = Nothing
Maybe just use the latter part:
Set sys = CreateObject("Microsoft.Update.SystemInfo")
MsgBox sys.RebootRequired
Set sys = Nothing
I am not really familiar with the Windows Update Agent Object Model.
Reboots: There are many registry locations that can be involved in triggering a reboot (warning). Get-PendingReboot-Query. And a similar PowerShell script.
Here are some registry locations I have found that are involved in Windows rebooting (definitely not exhaustive):
HKLM\SOFTWARE\Microsoft\Updates : UpdateExeVolatile
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager : PendingFileRenameOperations
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer : InProgress
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing : RebootPending
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update : RebootRequired
HKLM\SYSTEM\Setup : SystemSetupInProgress
And computer rename operation in progress:
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName : ComputerName
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName : ComputerName
CCMClientSDK: And then there are some WMI calls to check for SCCM 2012 Client Reboot Pending Status
. CCMClientSDK.IsHardRebootPending
and CCMClientSDK.RebootPending
. Check the Get-PendingReboot-Query script.