2021-02-21

Windows 10 upgrade fails with error 0x8007001F - 0x20006 ... and a number of other errors

What better pastime on a weekend than trying to upgrade a laptop with Windows 10 1809 installed on it that refuses to let itself get upgraded or install any Windows updates for that matter? I really cannot think of anything ...

But lets start from the top: This laptop has Windows 10 1809 Education installed on it. With an UBR value of 253, which puts its update status on January 8th 2019 ... more than 2 years since the last Windows update was installed.

Every attempt to install a newer Windows 10 version would always fail with the error 0x8007001F - 0x20006, accompanied with the error message "The installation failed in the SAFE_OS phase with an error during REPLICATE_OC operation." (in German: "Die Installation war nicht erfolgreich. In der Phase SAFE_OS ist während des Vorgangs REPLICATE_OC ein Fehler aufgetreten.")

And every attempt to install any regular Windows updates would throw an "This Update is not Applicable to your Computer." error (in German: "Das Update ist nicht für Ihren Computer geeignet.")

But this is just where it all starts ...

If you search the internet for any of these errors you will find a ton of "guides" that seem to copy every single "trick" that might have fixed _something_ at some point in time. And they seem to have copied everything from each other, sometimes even including non-existing command parameters and typos. Good thing their websites at least look professional. *cough*

Though since this is not my first broken Windows 10 installation I at least tried some of the suggested commands, well aware that there is at least a chance for them to fix my problem, however unlikely. Do not get me wrong, these commands have their uses and do fix various problems/issues, but this particular system was given to me by an experienced Windows sysadmin who had already tried all these tricks himself. I just did them again to make sure he did not miss anything ... and to not fall victim to the "the user always lies" trope that I have to deal with at my $dayjob.

So I did the usual commands:

sfc /scannow

dism /Online /Cleanup-Image /RestoreHealth

I even went so far as to download the latest Windows 10 1809 ISO from the Volume Licensing Service Center (VLSC) and used the (after extracting the Install.wim file from it) slightly less known command

dism /Online /Cleanup-Image /RestoreHealth /Source:WIM:Install.wim:1 /LimitAccess

Where the ":1" part of the "/Source" parameter tells it to use the first image inside the Install.wim file, which is "Education" - since that is what is installed on this laptop.

All commands completed successfully without errors. No corruptions found and nothing got repaired.


I also reset Windows Update itself with the following commands:

net stop bits

net stop wuauserv

ren %systemroot%\SoftwareDistribution SoftwareDistribution.bak

ren %systemroot%\system32\catroot2 catroot2.bak

net start bits

net start wuauserv

You sometimes find guides that want you to stop/start two more services (appidsvc and cryptsvc) or guides that want you to execute these two additional commands after renaming the folders.

sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)

sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)

I will not go into any details what these commands are doing exactly, I am sure you can find that out on your own.


The Windows troubleshooting tool for Windows Update also did not find any issues - or at least was not able to identify them.


So in the end none of these "magical fixes" you find on all these "guides" on the internet did anything. Both the feature upgrades to a newer Windows 10 version and the regular Windows 10 updates were still failing.


Digging through "dism.log" under "C:\Windows\Logs\DISM\" and "CBS.log" under "C:\Windows\Logs\CBS\" after running the "sfc" and "dism" commands above did not show anything of substance either. They are hard to read and even if you find errors and warnings in them ... they are probably supposed to be there. I do not think I have ever seen a "CBS.log" without any errors in it.

The file "C:\$Windows.~BT\Sources\panther\setupact.log" from the failed feature upgrades was not of much use either. While I did find the error 0x8007001F referenced in it I could not find anything useful in the log lines leading up to the error.


I then remembered that I had to deal with a number of Windows 10 installations unwilling to let themselves upgraded in the past - which I had documented here. While the error back then was "0x80070570 - 0x2000c" with the error message "The installation failed in the SAFE_OS phase with an error during APPLY_IMAGE operation." it was close enough to tickle my interest. Back then the error was caused by certain IIS features being installed.

So I headed to the control panel to check whether that might be the cause here too. But what I got was not exactly what I was expecting. The window was ... empty.


I had never seen that issue before so I was quite confused at first. Next I checked with PowerShell what it could tell me.

Get-WindowsOptionalFeature -Online

But instead of giving me the output I was expecting I basically got the same treatment the control panel was giving me, except this time I got an error returned too.

Error: 0x800f0805
The specified package is not valid Windows package.

Now if you go on your next internet search for that error you will get a lot of the same suggestions you already tried before. "sfc /scannow", "dism /RestoreHealth", resetting to a previous system restore point. But also some more creative suggestion, like creating a new Administrator account - whatever that is supposed to do. Or setting the "Windows Modules Installer" service to automatic start instead of manual. (Do not do that.)

One suggestion however was new, or at least I had not seen it before. Running the following command:

reg delete HKLM\COMPONENTS /v StoreDirty

Since that registry value did not exist there was no point in even trying it, but might as well mention it here for documentation purposes. The command is not new to Windows 10 or anything. It is mentioned in a number of places all the way back to 2007 (and probably even further). I just had never encountered it before.

But even if that registry value did not exist it did put me on the right track for all the issues this laptop was throwing at me. The failing Windows updates, the failing feature upgrades, the empty Windows features window and the failing PowerShell command. They all ended up being caused by the same problem.

In the end I found the hint I needed in a forum post by user "seanius" on the Sysnative.com forum. He was describing the exact same issues I was having. He went through all the steps I went through, and more, just to end up with a still broken system. Until he found an older thread on the same forum where they managed to actually fix a machine as broken as the laptop I had to deal with.

Looking at the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing" gave me the following result:


The fact alone that "Packages" had no subkeys was reason enough to suspect that this might be causing at least some of my issues. So I quickly installed a virtual machine with Windows 10 1809 (since that was the version installed on the laptop) and took a look at the same registry key there.


As you can see, not only does "Packages" have subkeys here, the entire "Component Based Servicing" registry key has a lot more subkeys than on the broken laptop. So I simply exported the entire "Component Based Servicing" registry key from the virtual machine and transferred it over to the laptop.

After creating a backup of the laptop's registry key I imported the .reg file from the virtual machine, ran the "sfc /scannow" and "dism /RestoreHealth" commands just for good measure and then restarted the machine.

Checking the Windows feature list and the "Get-WindowsOptionFeatures -Online" PowerShell command now gave me the results I was expecting and I was able to install Windows Servicing Stack updates without errors. The latest cumulative Windows update for Windows 10 1809 still failed to install though. Instead I tried to run the feature upgrade for Windows 10 20H2 and it actually succeeded this time. Afterwards Windows Update was also able to successfully install all remaining Windows Updates.

The laptop is now running the latest Windows 10 version at a current patch level. Case closed. The laptop's owner is happy. And I have learned a new trick that actually deserves an entry in a guide.


No comments:

Post a Comment