Check whether Windows is pending a reboot
Registry keys and a PowerShell example to detect a pending reboot after an update.
Windows sometimes reports that a restart is required after an update or a software installation. This state is recorded in several places in the registry; the keys below make it quick to check.
Registry keys to check
| Location (HKLM) | Type | Meaning |
|---|---|---|
SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending |
key | A restart is pending for component servicing (CBS) |
SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired |
key | Windows Update requires a restart |
SYSTEM\CurrentControlSet\Control\Session Manager, value PendingFileRenameOperations |
value | Files will be replaced or deleted at the next startup |
PowerShell example
$pendingKeys = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending',
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'
) | Where-Object { Test-Path $_ }
$sessionManager = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue
[pscustomobject]@{
PendingKey = [bool]$pendingKeys
PendingFileRename = [bool]$sessionManager.PendingFileRenameOperations
}
Notes
The example covers only three locations; other keys can also indicate a pending restart. For a more complete check, see the source article: Adam the Automator - Pending reboot registry.