"We couldn’t complete the updates. Undoing changes" endless loop

I need help, everytime I start/restart/shutdown my computer, it tries to install Windows Updates and fails, and showing this:

enter image description here

I am able to boot into my computer normally and use it without problems AFTER A RATHER LONG WAIT...

I have run the following:

dism /online /cleanup-image /startcomponentcleanup
dism /online /cleanup-image /scanhealth
dism /online /cleanup-image /restorehealth
dism /online /cleanup-image /restorehealth /source:E:\sources\install.wim
sfc /scannow

Countless times, needless to say, no corruption detected and everything fixed——except this endless update failure loop...

I want to uninstall these updates, but they haven't been properly installed;

I opened appwiz.cpl\installed updates, identified four updates that might had caused the problem:

enter image description here

Only KB4580419 has an "Uninstall" option, the other three don't have.

Tried these, observed no effect;

wusa /uninstall /kb:4594440 /quiet /norestart
wusa /uninstall /kb:4562830 /quiet /norestart
wusa /uninstall /kb:4593175 /quiet /norestart
wusa /uninstall /kb:4580419 /quiet /norestart

Removed /quiet argument and tried to uninstall one update, it opened Windows Update Standalone Installer, it runs and hangs, in taskmgr its status is suspended, clicked cancel without effect, fortunately I can kill it in taskmgr;

I had run this:

dism /online /get-packages /format:table

Found a lot packages with state "Install Pending" and "Staged"

Ran this:

(Get-WindowsPackage -Online | Where {$_.PackageState -eq "Staged" -or $_.PackageState -eq "InstallPending"}).PackageName

The result:

Microsoft-OneCore-DeveloperMode-Desktop-Package~31bf3856ad364e35~amd64~~10.0.19041.662
Microsoft-OneCore-Graphics-Tools-Package~31bf3856ad364e35~amd64~~10.0.19041.488
Microsoft-WebDriver-Package~31bf3856ad364e35~amd64~~10.0.19041.610
Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~amd64~en-US~10.0.19041.662
Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~amd64~fr-FR~10.0.19041.662
Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~amd64~zh-CN~10.0.19041.662
Microsoft-Windows-Hello-Face-Package~31bf3856ad364e35~amd64~~10.0.19041.662
Microsoft-Windows-LanguageFeatures-Handwriting-zh-cn-Package~31bf3856ad364e35~amd64~~10.0.19041.488
Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~amd64~en-US~10.0.19041.488
Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~amd64~fr-FR~10.0.19041.488
Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~amd64~zh-CN~10.0.19041.488
Microsoft-Windows-Media-Features-Package~31bf3856ad364e35~amd64~~10.0.19041.685
Microsoft-Windows-MediaPlayer-Package~31bf3856ad364e35~amd64~~10.0.19041.546
Microsoft-Windows-Notepad-FoD-Package~31bf3856ad364e35~amd64~fr-FR~10.0.19041.488
Microsoft-Windows-Notepad-FoD-Package~31bf3856ad364e35~amd64~zh-CN~10.0.19041.488
Microsoft-Windows-Printing-WFS-FoD-Package~31bf3856ad364e35~amd64~fr-FR~10.0.19041.488
Microsoft-Windows-Printing-WFS-FoD-Package~31bf3856ad364e35~amd64~zh-CN~10.0.19041.488
Microsoft-Windows-StorageManagement-FoD-Package~31bf3856ad364e35~amd64~en-US~10.0.19041.488
Microsoft-Windows-StorageManagement-FoD-Package~31bf3856ad364e35~amd64~fr-FR~10.0.19041.488
Microsoft-Windows-StorageManagement-FoD-Package~31bf3856ad364e35~amd64~zh-CN~10.0.19041.488
Microsoft-Windows-StorageManagement-FoD-Package~31bf3856ad364e35~amd64~~10.0.19041.662
Microsoft-Windows-UserExperience-Desktop-Package~31bf3856ad364e35~amd64~~10.0.19041.662
Microsoft-Windows-WordPad-FoD-Package~31bf3856ad364e35~amd64~~10.0.19041.662
Microsoft-Windows-Xps-Xps-Viewer-Opt-Package~31bf3856ad364e35~amd64~~10.0.19041.662
Package_for_DotNetRollup~31bf3856ad364e35~amd64~~10.0.4300.1
Package_for_KB4562830~31bf3856ad364e35~amd64~~10.0.1.3
Package_for_RollupFix~31bf3856ad364e35~amd64~~19041.685.1.6

Then I ran this:

(Get-WindowsPackage -Online | Where {$_.PackageState -eq "Staged" -or $_.PackageState -eq "InstallPending"}).PackageName | %{dism /Online /Remove-Package /PackageName:${_} /norestart}

Found $SysReset, $WINDOWS.~BT, $WinREAgent, Recovery, "System Volume Information" folders in C:, their contents:

C:\$SysReset\CloudImage
C:\$SysReset\Logs
C:\$SysReset\MDM
C:\$SysReset\OldOS
C:\$SysReset\Scratch
C:\$SysReset\Logs\PushButtonReset.etl
C:\$SysReset\Logs\SessionID.xml
C:\$SysReset\Logs\setupact.log
C:\$SysReset\Logs\setuperr.log
C:\$SysReset\Logs\Timestamp.xml
C:\$WINDOWS.~BT\Sources
C:\$WINDOWS.~BT\Sources\Panther
C:\$WINDOWS.~BT\Sources\Panther\actionable.xsl
C:\$WINDOWS.~BT\Sources\Panther\AltData.cab
C:\$WINDOWS.~BT\Sources\Panther\appraiser.sdb
C:\$WINDOWS.~BT\Sources\Panther\Appraiser_Data.ini
C:\$WINDOWS.~BT\Sources\Panther\Appraiser_TelemetryRunList.xml
C:\$WINDOWS.~BT\Sources\Panther\CompatData_2020_12_18_13_43_45_3_00000021.xml
C:\$WINDOWS.~BT\Sources\Panther\CompatData_2020_12_18_13_43_48_3_00000021.xml
C:\$WINDOWS.~BT\Sources\Panther\compatscancache.dat
C:\$WINDOWS.~BT\Sources\Panther\DeviceBlock_Modern.xsl
C:\$WINDOWS.~BT\Sources\Panther\diagerr.xml
C:\$WINDOWS.~BT\Sources\Panther\diagwrn.xml
C:\$WINDOWS.~BT\Sources\Panther\Dissmissable_Modern.xsl
C:\$WINDOWS.~BT\Sources\Panther\Full.xsl
C:\$WINDOWS.~BT\Sources\Panther\full_connected.xsl
C:\$WINDOWS.~BT\Sources\Panther\IB85T7xeB0WQR8TH.4.4.0.0_APPRAISER_EverythingSys.bin
C:\$WINDOWS.~BT\Sources\Panther\IB85T7xeB0WQR8TH.4.4.0.0_APPRAISER_HumanReadable.xml
C:\$WINDOWS.~BT\Sources\Panther\IB85T7xeB0WQR8TH.4.4.0.0_APPRAISER_SetupOutput.xml
C:\$WINDOWS.~BT\Sources\Panther\IB85T7xeB0WQR8TH.4.4.0.0_APPRAISER_SetupOutputHw.xml
C:\$WINDOWS.~BT\Sources\Panther\ie6png.js
C:\$WINDOWS.~BT\Sources\Panther\img
C:\$WINDOWS.~BT\Sources\Panther\modern.xsl
C:\$WINDOWS.~BT\Sources\Panther\namedTemplates.xsl
C:\$WINDOWS.~BT\Sources\Panther\Overview.xsl
C:\$WINDOWS.~BT\Sources\Panther\Overview_connected.xsl
C:\$WINDOWS.~BT\Sources\Panther\PreDownload_AppUninstall.xsl
C:\$WINDOWS.~BT\Sources\Panther\Resources
C:\$WINDOWS.~BT\Sources\Panther\Save.xsl
C:\$WINDOWS.~BT\Sources\Panther\Save_connected.xsl
C:\$WINDOWS.~BT\Sources\Panther\ScanResult.xml
C:\$WINDOWS.~BT\Sources\Panther\setupact.log
C:\$WINDOWS.~BT\Sources\Panther\setuperr.log
C:\$WINDOWS.~BT\Sources\Panther\SetupReports.css
C:\$WINDOWS.~BT\Sources\Panther\setupReportsLoc.css
C:\$WINDOWS.~BT\Sources\Panther\setup_strings.xml
C:\$WINDOWS.~BT\Sources\Panther\SummaryInfo_Modern.xsl
C:\$WINDOWS.~BT\Sources\Panther\SummaryReport.html
C:\$WINDOWS.~BT\Sources\Panther\tables.js
C:\$WINDOWS.~BT\Sources\Panther\urls.xml
C:\$WINDOWS.~BT\Sources\Panther\wica_strings.xml
C:\$WINDOWS.~BT\Sources\Panther\windlp.state-old.xml
C:\$WINDOWS.~BT\Sources\Panther\windlp.state.xml
C:\$WINDOWS.~BT\Sources\Panther\img\defaultApp.png
C:\$WINDOWS.~BT\Sources\Panther\img\defaultPlugins.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_battery.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_biometric.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_bluetooth.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_cdrom.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_default.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_diskdrive.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_display.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_floppydisk.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_hidclass.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_image.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_keyboard.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_modem.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_monitor.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_mouse.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_mtd.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_net.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_pcmcia.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_printer.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_sensor.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_smartcardreader.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_tapedrive.png
C:\$WINDOWS.~BT\Sources\Panther\img\device_usb.png
C:\$WINDOWS.~BT\Sources\Panther\img\failure.png
C:\$WINDOWS.~BT\Sources\Panther\img\setupactiondefault.png
C:\$WINDOWS.~BT\Sources\Panther\img\warning.png
C:\$WINDOWS.~BT\Sources\Panther\img\wontwork.png
C:\$WINDOWS.~BT\Sources\Panther\img\works.png
C:\$WinREAgent\Scratch
C:\System Volume Information\EDP
C:\System Volume Information\IndexerVolumeGuid
C:\System Volume Information\Windows Backup
C:\System Volume Information\WindowsImageBackup
C:\System Volume Information\WPSettings.dat
C:\System Volume Information\Chkdsk\Chkdsk20201221110016.log
C:\System Volume Information\EDP\Recovery
C:\System Volume Information\Windows Backup\Catalogs
C:\System Volume Information\Windows Backup\Catalogs\GlobalCatalogLock.dat
C:\System Volume Information\WindowsImageBackup\SPPMetadataCache

C:\Windows\SoftwareDistribution:

Folder PATH listing for volume Windows
Volume serial number is 641B-479B
C:\WINDOWS\SOFTWAREDISTRIBUTION
├───DataStore
│   └───Logs
├───Download
│   ├───40c9e31f3fa1731b9f71da79d884fbe6
│   ├───ae6a47efe9fd0e03da033575571e7c6d
│   │   └───cbshandler
│   ├───baa66f28726f701d6508d16b26235240
│   │   ├───Metadata
│   │   │   └───Windows10.0-KB4593175-x64-EXPRESS
│   │   └───Package_for_KB4593175~~amd64~~19041.680.1.0
│   │       ├───amd64_microsoft-windows-s..-installers-onecore_31bf3856ad364e35_10.0.19041.680_none_c984780e045b899c
│   │       ├───amd64_microsoft-windows-s..cingstack-onecoreds_31bf3856ad364e35_10.0.19041.680_none_9220853e80a07cef
│   │       ├───amd64_microsoft-windows-s..ck-mof-onecoreadmin_31bf3856ad364e35_10.0.19041.680_none_f789f0d48e0af1d8
│   │       ├───amd64_microsoft-windows-s..formers-shell-extra_31bf3856ad364e35_10.0.19041.680_none_c7d6d41fdc1eaa2b
│   │       ├───amd64_microsoft-windows-s..gstack-boot-onecore_31bf3856ad364e35_10.0.19041.680_none_338f2b4bcf702713
│   │       ├───amd64_microsoft-windows-s..ingstack-base-extra_31bf3856ad364e35_10.0.19041.680_none_fcccf2982248b1b5
│   │       ├───amd64_microsoft-windows-s..k-transformers-core_31bf3856ad364e35_10.0.19041.680_none_49fba22634662d4d
│   │       ├───amd64_microsoft-windows-s..llers-onecore-extra_31bf3856ad364e35_10.0.19041.680_none_01a2caa8222e0a15
│   │       ├───amd64_microsoft-windows-s..ngstack-onecorebase_31bf3856ad364e35_10.0.19041.680_none_ce4cfd4440d93c2d
│   │       ├───amd64_microsoft-windows-s..ransformers-onecore_31bf3856ad364e35_10.0.19041.680_none_021ebd345a75567f
│   │       ├───amd64_microsoft-windows-s..stack-inetsrv-extra_31bf3856ad364e35_10.0.19041.680_none_16f82254009eecc1
│   │       ├───amd64_microsoft-windows-s..stack-termsrv-extra_31bf3856ad364e35_10.0.19041.680_none_f098d9f99ea89093
│   │       ├───amd64_microsoft-windows-servicingstack-inetsrv_31bf3856ad364e35_10.0.19041.680_none_12f53731c5ece5e4
│   │       ├───amd64_microsoft-windows-servicingstack-onecore_31bf3856ad364e35_10.0.19041.680_none_1c18fdd47e42b752
│   │       ├───amd64_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.19041.680_none_e72768c3263f99bc
│   │       ├───x86_microsoft-windows-s..-installers-onecore_31bf3856ad364e35_10.0.19041.680_none_6d65dc8a4bfe1866
│   │       ├───x86_microsoft-windows-s..cingstack-onecoreds_31bf3856ad364e35_10.0.19041.680_none_3601e9bac8430bb9
│   │       ├───x86_microsoft-windows-s..ck-mof-onecoreadmin_31bf3856ad364e35_10.0.19041.680_none_9b6b5550d5ad80a2
│   │       ├───x86_microsoft-windows-s..formers-shell-extra_31bf3856ad364e35_10.0.19041.680_none_6bb8389c23c138f5
│   │       ├───x86_microsoft-windows-s..gstack-boot-onecore_31bf3856ad364e35_10.0.19041.680_none_d7708fc81712b5dd
│   │       ├───x86_microsoft-windows-s..ingstack-base-extra_31bf3856ad364e35_10.0.19041.680_none_a0ae571469eb407f
│   │       ├───x86_microsoft-windows-s..k-transformers-core_31bf3856ad364e35_10.0.19041.680_none_eddd06a27c08bc17
│   │       ├───x86_microsoft-windows-s..llers-onecore-extra_31bf3856ad364e35_10.0.19041.680_none_a5842f2469d098df
│   │       ├───x86_microsoft-windows-s..ngstack-onecorebase_31bf3856ad364e35_10.0.19041.680_none_722e61c0887bcaf7
│   │       ├───x86_microsoft-windows-s..ransformers-onecore_31bf3856ad364e35_10.0.19041.680_none_a60021b0a217e549
│   │       ├───x86_microsoft-windows-s..stack-termsrv-extra_31bf3856ad364e35_10.0.19041.680_none_947a3e75e64b1f5d
│   │       ├───x86_microsoft-windows-servicingstack-inetsrv_31bf3856ad364e35_10.0.19041.680_none_b6d69bae0d8f74ae
│   │       ├───x86_microsoft-windows-servicingstack-onecore_31bf3856ad364e35_10.0.19041.680_none_bffa6250c5e5461c
│   │       └───x86_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.19041.680_none_8b08cd3f6de22886
│   └───SharedFileCache
├───PostRebootEventCache.V2
└───SLS
    ├───2B81F1BF-356C-4FA1-90F1-7581A62C6764
    ├───522D76A4-93E1-47F8-B8CE-07C937AD1A1E
    ├───7971F918-A847-4430-9279-4A52D1EFE18D
    ├───855E8A7C-ECB4-4CA3-B045-1DFA50104289
    ├───8B24B027-1DEE-BABB-9A95-3517DFB9C552
    ├───9482F4B4-E343-43B6-B170-9A65BC822C77
    └───E7A50285-D08D-499D-9FF8-180FDC2332BC

There were some errors in dism, the whole log is too long to be posted here, I managed to get dism logs generated tody, I uploded it to Google Drive:

https://drive.google.com/file/d/1HbsPtZ79KVQqaYMGLVA4jA4fMSef2iLC/view

What to do?

Update: opened the folder C:\Windows\Logs\CBS, there are more than one file, compressed it and uploaded to Google Drive:

https://drive.google.com/file/d/1gwRGCq1mJAp6S6J_mN8hnfw9A91hqSWb/view?usp=sharing

Winver:

enter image description here

This is the Update History, strangely everything is successfully installed, I deduced the trouble maker to be KB4592438 by date:

enter image description here

Currently there are two updates pending restart:

enter image description here

How to get rid of them?

Output of Get-WindowsUpdatelog:

https://drive.google.com/file/d/1dUPilcqpapLpzQzv7QVf9fzeVt37qq64/view?usp=sharing

What files should I delete, what registry keys should I remove in order to cancel the pending updates? Can I delete SoftwareDistribution folder?

It's strange, I ran the following commands:

Get-WindowsPackage -Online | Where {$_.PackageName -match "KB4592438"}
Get-WindowsPackage -Online | Where {$_.PackageName -match "KB4586876"}

No responce

In update history, KB4592438 is already successfully installed on 2020-12-26, but somehow it's still pending restart

Tried

wusa /uninstall /kb:4592438
wusa /uninstall /kb:4586876

The result(same error for both):

enter image description here

I had tried these:

net stop wuauserv
rd /s /q %systemroot%\SoftwareDistribution\Download
net start wuauserv
dism.exe /online /cleanup-image /revertpendingactions

No errors occured, the updates are still pending, it's still reverting... Can I cancel it now?

It has completed:

Deployment Image Servicing and Management tool
Version: 10.0.19041.572

Image Version: 10.0.19042.631

Reverting pending actions from the image...
The operation completed. Revert of pending actions will be attempted after the reboot.
The operation completed successfully.

The updates are still pending...

I had opened C:\Windows\WinSxs\Temp and found there were lots of items, since it is named Temp I assume it is only related to pending actions, is it safe to remove the folder? I will not remove it until confirmation, I am restarting my computer now.


Solution 1:

After four consecutive restarts without "...Undoing changes" blue screen, I can confirm I had solved it;

I had run:

(Get-WindowsPackage -Online | Where {$_.PackageState -eq "Staged" -or $_.PackageState -eq "InstallPending"}).PackageName | %{dism /Online /Remove-Package /PackageName:${_} /norestart}

Don't know if it contributes, don't know if it relevant;

I think this is solved by(not sure, but definitely relevant):

net stop wuauserv
rd /s /q %systemroot%\SoftwareDistribution\Download
net start wuauserv
dism /online /cleanup-image /revertpendingactions
dism /online /cleanup-image /startcomponentcleanup

Now Settings says my device is up to date:

enter image description here

But I still don't know what caused it in the first place... However I wanted to cancel pending restart updates to prevent failure and roll back, this definitely solves it.

If you want to investigate the cause, please click this:

https://drive.google.com/file/d/1dLShNyo_ww3_QBmpdWJdzwQiC_YI2cMk/view?usp=sharing