Sunday, August 19, 2018

Windows 10 upgrade from 1709 to 1803 kept failing at 86% no matter what.

Windows 10 upgrade from 1709 to 1803 fails. Maybe other upgrades too? Provisioning may be the reason for the failure. 

Symptoms: Installation stops at 86% no matter what, reverts back to 1709 and gives an Error Code: 0xC1900101-0x4001E  "The installation failed in the SECOND_BOOT phase with an error during PRE_OOBE operation"

Since April 2018, My Windows 10 has been trying to update itself to version 1803 and every single time the update has failed. So it took several months to succeed, but finally today (2018-8-19) I got my Windows updated to 1803 and no clean install was needed. All my software and app's are still in place. That was the main reason to keep trying, installing all the app´s again was not an option. 

When automatic update fails, there are some alternative solutions. Lots of articles suggest removing 3'rd party antivirus software, external devices etc. Some sites suggest disabling Intel virtualization etc. but according to my experience it's nonsense. After trying all that and a lot more, I also chose to update my motherboards and SSD's firmware as suggested in some sources. That obviously solved nothing either. 

When automatic update had failed several times, it was time to try Windows Update Assistant. It may have solved some cases, but not this one. After that, I took some time using Media Creation tool to create DVD for installation. As expected, it failed too. Then I used it to create bootable USB and tried updating from it. Same crash happened again. 

At this point I figured out that I need to find out the real reason behind the problem. By googling around, I figured out that there is no definitive answer for the error code given by Windows. Finally I found out that there are hidden logs created during the update process, telling the real reason for crash. They are the only way to figure out what really caused the crash. 

The answer lies within "setuperr" -logfile which Microsoft places into hidden folder structure just to make things a bit more complicated. File "setuperr" can usually be found from folder: "C:\$Windows.~BT\source\panther\". Should it not be readable over there (user rights), you can copy it to alternative location and read using notepad etc. 


ERROR:

In my case the fatal error was found at last line of "setuperr" - logfile:
2018-08-18 15:45:16, FatalError [0x090001] PANTHR Exception (code 0xC0000005: ACCESS_VIOLATION) occurred at 0x00007FFF80CF494B in C:\Windows\System32\provengine.dll (+000000000000494B). 
Minidump attached (99815 bytes) to diagerr.xml and C:\Windows\Panther\mnd68D9.diagerr.mdmp.

At this point I started googling around about Provengine and figured out that it's related to Windows 10 Provisioning packages which are located at C:\Windows\Provisioning -folder and registry tree HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning. As I have installed my Windows 10 from the scratch couple of years ago, I should have only Microsoft's default packages, so it seemed that something (Microsoft probably) has messed my registry settings. 

Having a Windows 10 as virtual machine also, I was able to compare the folder structures both in registry and C:\Windows\Provisioning and figured out that there are some differences in the registry tree though there should not be, so I decided to try to replace "Proviosioning" tree by copying it from my virtual machine. At this point I also found out that someone else had tried this too, so I decided to give it a go. 

Edit (2018-8-20): I've checked also Windows Home versions registry and Provisioning tree is very similar in both so I've added both Pro and Home registry into this document in case you have no access to suitable 1709 version. 

SOLUTION  (Or how I finally got my Windows Updated to 1803)

NOTE! Actions suggested here require using registry editor (regedit)! If you don't understand what you are doing, don't do it and stay with 1709 version or ask some technical person to help you! Make sure your problem is also with provengine.dll, otherwise you'll just probably damage your Windows even more! Try this at your own risk. I can't quarantee this will work with your system! Be careful! Do not mess around registry elsewhere but under KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning


STEPS:

YOU NEED WORKING REGISTRY BRANCH, GET ONE FROM ANOTHER PC WITH WINDOWS 1709 INSTALLED OR DOWNLOAD ONE I'VE CREATED

1) Export registry tree KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning 
Select "Provisioning" and right click "Export"... and save file as "provisioning.reg"

Edit (2018-8-20): I've created registry entries for both Windows 10 Pro and Windows 10 Home in case you have no Windows v. 1709 available. There seem to be only minor differences in these files. Both files are in txt -format, so you need to rename one before you can import. I used the Pro version to fix my registry. I can't guarantee these will work for you!

ON A MACHINE WHERE UPDATE FAILS

Importing registry may be a bit harder. I deleted all the old keys (under Provisioning naturally) first as there were some extra branches under provisioning which did not exist in my virtual Windows. Anyway, removing them required that I took the ownership of keys first as I'm not usually running my system as an Administrator. After that you may proceed:

2) Make backup of your "KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning" 
just in case all fails and you need to get them back (don't know why though). If you are still reading this, there's a big change they're corrupted anyway so... 


REMOVE SUBKEYS UNDER: KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning

3) You need to start regedit as Administrator or as with SYSTEM account.
4) Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning
5) Delete everything inside Provisioning (See how to take ownership if needed)
6) Using regedit.exe as administrator to Import Provisioning registry settings (provisioning.reg) you created at the other machine. 
7) If there are differences between files in subfolders of C:\Windows\Provisioning you may copy files to there also from another PC.

Note: I renamed the folder "C:\Windows\Provisioning" to "Provisioning.old" before copying. As I have a Virtual Machine with identical setup, I was able to copy the folder incredients from there. When comparing data though it seemed identical so I guess that fixing registry was/is enough. 

That's it. Now you can retry update again and it should go pass 86% and Windows 1803 should work after installation is completed. 

Btw: If you renamed old Provisioning -> Provisioning.old like I did:

To clean up "provisioning.old", you may need to use CMD (Execute it as Administrator) and take the ownership of incredients:

takeown /f "C:\Windows\Provisioning.old"​
takeown /f "C:\Windows\Provisioning.old\Packages"
icacls "C:\Windows\Provisioning.old\Packages" /grant Admin:F
cd Packages
del *.*
rmdir Packages
takeown /f "C:\WINDOWS\Provisioning.old\Cosa\"
takeown /f "C:\WINDOWS\Provisioning.old\Cosa\Microsoft"
icacls "C:\WINDOWS\Provisioning.old\Cosa\Microsoft\Microsoft.Windows.Cosa.Desktop.Client.ppkg" /grant Admin:F
etc...


Great thanks to Microsoft for making our lives so hard! I wonder how many people will end up doing clean install or buying new PC after all the frustration with 1803 update.  

P.S. If you don't have another Windows machine where you could copy the registry settings for Provisioning, you may consider creating a virtual Windows 10 machine using for example VmWare workstation player.  https://www.vmware.com/products/workstation-player.html.

Testing private Methods in C#

Testing private methods in a C# can be a bit challenging. This is just to remember what's needed. [TestClass] private MyUnit _myUni...