In rare cases, Windows may repeatedly prompt you to restart the computer after installing updates. Moreover, Windows Update continues to display the “Restart required, Pending restart
” message no matter how many times you restart a computer.
This issue may be caused by a failed Windows Update installation where the update failed to apply changes to the system image and remained in an incomplete (pending) state. Let’s try to cancel the pending update installation and break the update restart loop.
Open a PowerShell console as an administrator and check for any update packages that require the computer to restart (with PendingReboot or InstallPending status). Run the command:
dism /online /get-packages /format:table | Select-String "Pending"
Or this PowerShell command (provides cleaner output):
Get-WindowsPackage -Online | Where-Object { $_.PackageState -like '*Pending*' }
In this example, Windows Update indicates that a restart is required to complete the package installation and to apply the changes. If, after restarting the computer, the component status still shows a pending reboot, you’ll need to cancel the deferred update installation.
Run the command shutdown /f /r /o /t 0
to restart a computer and boot into Windows Recovery environment (or boot from any LiveCD, DaRT recovery disk, or a Windows installation image).
To cancel scheduled updates with a ‘Pending’ status, run the following command (assuming that the Windows partition is assigned the C:\ drive letter )
DISM /image:C:\ /ScratchDir:C: /cleanup-image /RevertPendingActions
This will undo any pending actions from previous Windows Update maintenance operations.
If the DISM command doesn’t help, try manually canceling pending updates by deleting the pending.xml file:
del C:\Windows\WinSxS\pending.xml
del C:\Windows\WinSxS\cleanup.xml
(the file may be missing.)
del C:\Windows\SoftwareDistribution\Download\*.*
(clear the cache of downloaded updates)
Then run regedit and load the registry hive C:\WINDOWS\system32\config\Software
from the offline Windows image.
Navigate to the loaded registry hive, expand HKLM\SYSTEM\CurrentControlSet\Control\Session Manager
key and delete the PendingFileRenameOperations parameter.
Save the changes to the file by unloading the registry hive (File -> Unload hive).
Restart the computer and verify that the pending Windows updates no longer appear in the list.
Then, verify the Windows image integrity and repair the system image files by using the following commands:
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow