X

Fix Windows Update error 80070003 like a boss

In case Windows Update error 80070003, Windows Update ran into a problem, keeps appearing in Windows 7, 8, 8.1 or 10 despite using all possible solutions and Fix It tools, there is one somewhat trivial and one advanced fix for this headache.

Windows Update error code 80070003

Warning: please try typical Windows Update repair options first! Make sure your drives have enough free space, run a full file system check and try repairing or reinstalling Windows Update.

The first solution also applies when Windows Update stalls forever at about 1-5% while trying to download new updates. This can be verified by opening Event Viewer, expanding the Applications and Services Logs, Microsoft, Windows, WindowsUpdateClient, Operational and checking for error events with ID 31, Windows Update failed to download an update.

Event Viewer, WindowsUpdateClient error 31

The second solution applies after using a not-so-good third-party partitioning tool (EaseUS Partition Master is the most infamous of these) that messes up partitions and their ID-s. This one also results in the “Could not find the Recovery Environment” error while trying to Refresh or Reset your PC in Windows 8/8.1 or Windows 10, inability to turn on Recovery Agent with the reagentc /enable command, and the inability to upgrade to Windows 10 from an earlier version of Windows.

The solution for the corrupted or missing Sessions folder problem

Windows Update downloads patches into the %windir%\servicing\Sessions folder, where %windir% means the full path to your Windows installation folder, C:\Windows in most cases. All hell breaks loose if the Sessions folder becomes corrupted,  and no current Fix It or troubleshooting tool is able to resolve this recurring WU error code 80070003.

To check if your device is a victim of this particular problem, open Windows Explorer (in Windows 7) or File Explorer (in Windows 8 and later), type or copy-paste %windir%\servicing into Address Bar and press Enter key to navigate to the folder.
In most cases, the Sessions folder does not exist at all, but there is probably a file named Sessions instead. This means you can proceed with the current solution.

If you do see the Sessions folder and you are able to open it and it does have several .xml files inside, then the file system permissions for the folder are incorrect and prevent Windows Update from working correctly. Right-click the Sessions folder, choose Properties and open Security tab from the top. Click Edit and make sure the following permissions exist:

  1. ALL APPLICATION PACKAGES – Read & execute, List folder contents, Read  (only in Windows 8 and later);
  2. SYSTEM – Read & execute, List folder contents, Read;
  3. Administrators – Read & execute, List folder contents, Read;
  4. Users – Read & execute, List folder contents, Read;
  5. TrustedInstaller – all checkboxes ticked (aka Full control).

If neither of the above is your case, please jump to the Solution for bad partitioning and RAW file system solution instead.

Oh, let’s remove the corrupted file and create the missing folder then – I mean, how hard can it be? 😉 In Windows, it turns out to be quite some task due to file system permissions. If you happen to have a bootable Linux media, and your PC-s drives are not encrypted, you might find it easier to boot from it, mount Windows partition and simply rename the sessions file to sessions.old, create a new folder and name it to Sessions.

In Windows, you need to first take ownership of the parent folder to gain any usable rights to the corrupted sessions file. The default owner of the servicing folder is usually TrustedInstaller.

Navigate back to the Windows folder, right-click or tap and hold on the servicing folder and choose Properties.

Windows folder, right-click on servicing

In the Servicing Properties window, open Security tab and click or tap the Advanced button.

PS! If you see a SID number (starts with S-I-15-3-1024) instead of a name in the list, please do not remove it! This is probably a capability SID for system access. In Windows 10 version 1809, there are over 300 capability SIDs and removing their access to Registry keys or file system could cause problems in the future.

Servicing Properties window, click Advanced

Taking ownership in Windows 7

In Windows 7, open the Owner tab and click Edit.

Windows 7, Advanced Security Settings for servicing, Owner tab

Click your user account name (do not choose any groups!) in the Change owner to list, tick the Replace owner on subcontainers and objects check box and click OK.

Windows 7, Advanced Security Settings for servicing, Owner tab, replacing the owner

Then a warning appears that you need to close and reopen this object’s properties before you can view or change permissions. Click OK.

Windows 7, you will need to close and reopen this object’s properties

Taking ownership in Windows 8, 8.1 and 10

In Windows 8 and newer, click or tap the Change link next to the Owner line.

Windows 8, Advanced Security Settings for servicing. Click Change.

In the Select Users or Groups window, type your user account name and click Check Names. Your user name becomes underlined and your device’s name is added automatically, click OK.

Windows 8, Select Users or Groups

Back in the Advanced Security Settings window, tick the Replace owner on subcontainers and objects check box and click OK.

Windows 8, Advanced Security Settings for servicing, changing the owner

Adding your account to the permissions list

After taking ownership, you end up back in the servicing Properties window, Security tab. Click or tap Edit under the Group or user names list.

Servicing Properties, click Edit

Permissions for servicing window opens. You need full control over the folder and its contents, so please click or tap Add.

Windows 8, Permissions for servicing. Click Add.

In the Select Users or Groups dialog, type your user account name and click Check Names on the right. The user name becomes underlined and your device’s name is added to the beginning, click OK.

Windows 8, Select Users or Groups

Back in the Permissions for servicing window, click or tap your user name in the list. Then tick the Full control check box in Allow column to automatically grant all other permissions.
Click OK.

Permissions for servicing, grant Full Control to your account.

Windows then kindly reminds that changing permission settings on system folders can reduce security or cause problems with accessing files. As the reduced security is required temporarily, click Yes.

Windows Security warning, click Yes.

Open the servicing folder in Windows/File Explorer. Right-click or tap and hold on the corrupt sessions file and choose Delete.
Make sure you are deleting a file, not a folder!

Windows, Servicing folder. Right-click the corrupt ‘sessions’ file and click Delete.

Next, right-click or tap and hold on an empty space (not on a file or a folder) and choose New, Folder. Keyboard shortcut for this is Ctrl+Shift+N.

Explorer, right-click in an empty space and click New, Folder.

Rename the new folder to Sessions and press Enter key once.

Explorer, name the new folder as ‘Sessions’.

The safest bet is to restart your device now and then verify that Windows Update is able to download and install new updates.

If everything is ok, browse to Windows folder with Windows/File Explorer and open properties for the servicing folder. Click or tap to open the Security tab, click Edit and remove your user account name from the list – you do not need to have full control over the folder anymore. Then click the Advanced button in the Servicing Properties window, Security tab and set the folder owner back to TrustedInstaller – type NT Service\TrustedInstaller if you cannot find the item in the list. And that’s it! 🙂

The solution for bad partitioning and RAW file system (please read very carefully!)

Another common reason for Windows Update error 80070003 and “Could not find the Recovery Environment” errors while trying to Refresh or Reset your PC is bad partition ID-s after using a non-Microsoft partitioning tool.

The following instructions are for advanced users only, do take a full backup of your device before proceeding. You have been warned.

To check for the existence of this problem, open Start menu or Start screen, type cmd, right-click Command Prompt or cmd.exe in the results and choose Run as administrator. This is also known as opening an elevated Command Prompt.

First, let’s determine if your device is UEFI/GPT or BIOS/MBR based if you do not know this already. Type bcdedit and press Enter.
If the path field in Windows Boot Manager section has “EFI” in it, your device is in UEFI boot mode. Take note of the boot mode, you might need it later.
Please note that only 64-bit (x64) Windows installations can be UEFI/GPT based.

Windows 10, Command Prompt, bcdedit, UEFI boot mode

In the black Administrator Command Prompt (aka elevated Command Prompt) window, type the following commands and press Enter key after each one:

  • diskpart
  • select disk 0
  • list partition
  • list volume

If this results in more than one OEM partition in the Type field, your device may be affected by bad partitioning. Please note that many Lenovo, Dell, etc devices with Windows preinstalled also have a 40 MB OEM partition in addition to the default 350-1000 MB OEM partition. This is normal and does not indicate a problem. In such a case, two OEM partitions are OK; more than two probably indicate a problem.

This should help in finding partitions that should be Recovery (aka Windows RE or WinRE) instead of OEM and vice versa (minimum size for Windows Recovery Environment partition is 300 MB):

  • In Windows 8, the default Recovery partition size is 350 MB.
  • In Windows 8.1, the default Recovery partition size is 450 MB.
  • If your device was upgraded from Windows 8 to 8.1, it probably has both 350 MB and 450 MB Recovery partitions.
  • In Windows 10, the default Recovery partition size is 1000 MB.

It is normal for a device to have multiple Recovery partitions – usually, the very last partition (the one with the highest number) is also a Recovery partition that contains a manufacturer-customized recovery image and is about 8-15 GB in size.

Here is an example of messed up partitioning by EaseUS Partition Master: note the two OEM partitions (number 4 and 6). This device was upgraded from Windows 8 to 8.1, therefore it should have both 350 MB and 450 MB Recovery partitions. The first one is there (Partition 7), but the latter one is missing. Of the two listed OEM partitions, number 6 is labeled OEM and its size is 450 MB, so it must be the Recovery partition created by Windows 8.1 upgrade.
Partition 4 is correctly set as OEM in this example, but note the 40 MB Recovery partition (number 2). If you paid attention earlier, you already know that this is a common size for an OEM partition and that no recovery partition is so small. Therefore, Partition 2 must be set as an OEM partition in this example.

Diskpart, bad partitioning

If your device is unaffected, type exit and press Enter key – this solution does not apply. You can safely close the Command Prompt window now. See the Restore Windows RE tutorial to resolve the “Could not find the recovery environment” problem.

Also, please take a look at the Fs column of the list volume command output: if a volume is listed as RAW and your device does not have any unformatted drives, that volume needs checking: please scroll down to the “Resolving the RAW file system problem” section and follow these instructions first.

Before making any changes, do write down (or take a screenshot of) the current partition layout. Store the screenshot so that you can access it from another device (cloud service such as OneDrive, Tresorit, etc; or an external hard drive or USB stick). You can even use a digital photo camera or a camera-equipped phone for the task.
This helps a lot if you do something wrong and need to restore the original layout. Never skip this very important step! Another great idea is to create a full backup of your device.

To fix the mess, note the partition numbers for all partitions that have an incorrect type.
Type or copy-paste the following two commands and press Enter after each one (please note that the second command is different for UEFI/GPT and BIOS/MBR systems):

  • select partition <the number of the partition that should be Recovery> – for example, select partition 6
  • if your device is UEFI/GPT based: set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
  • if your device is BIOS/MBR based: set id=27

If necessary, repeat the commands for other partitions that should be Recovery.

In case your device has partitions that should be OEM (the 40 MB Partition 2 in this example), continue with the following two commands, pressing Enter after each one (please note that the second command is different for UEFI/GPT and BIOS/MBR systems):

  • select partition <the number of the partition that should be OEM> – for example, select partition 2
  • if your device is in UEFI/GPT boot mode: set id=bfbfafe7-a34f-448a-9a5b-6213eb736c22
  • if your device is in BIOS/MBR boot mode: set id=12

Again, repeat the commands for other partitions that should be OEM.

To verify that partition layout is now correct, type list partition and press Enter key.

Type reagentc /enable and press Enter key to turn Recovery Agent back on. You can now retry upgrading to Windows 10, or running Refresh Your PC or Reset Your PC.

If this solution did not completely resolve Recovery Agent and Recovery Partition problems, please see the Restore Windows RE tutorial on how to restore missing recovery environment files.

Resolving the RAW file system problem

Below is a real-world example from the comments: Volumes 1, 3, 4 and 5 are listed as RAW. Their sizes match those of partitions number 2, 6, 7 and 8 – so the Recovery partitions are having problems with their file system. This is also the cause for error 80070003 and it does not necessarily indicate problems with bad partitioning.

Windows 10, DiskPart, RAW volumes listed

In this example, all these volumes are hidden (do not have a drive letter assigned) and therefore cannot be checked with tools like Disk Check or chkdsk.
To resolve this, note the numbers of volumes listed as RAW and use commands select volume <the number of the RAW volume> and assign to add drive letters. For this particular example, the commands in DiskPart would be:

  • select volume 1
  • assign
  • select volume 3
  • assign
  • select volume 4
  • assign
  • select volume 5
  • assign
  • list volume

The last command shows new drive letters for the volumes. Take note of these.

Windows 8/8.1 and 10 are intelligent enough to detect and fix file system problems automatically after a drive letter has been assigned to a volume/partition. All it takes is one restart.
In older versions of Windows, you can open Windows Explorer and navigate to Computer to see all drives with their drive letters. Right-click on a drive that has the RAW file system and choose Properties. Open the Tools tab, click the Check now or Check button and follow instructions. You might need to reboot your computer if Disk Check asks you to do so. More detailed instructions are available in the Check disks in Windows guide at www.winhelp.us.
Please repeat this process for every volume listed as RAW.

After file system problems have been fixed, restart your device, try running Windows Update again and see if the problem has been resolved.

If it has, open elevated Command Prompt and run DiskPart to remove the letters from the repaired partitions/volumes: Recovery partitions must be hidden.
In this particular example, the commands in DiskPart would be:

  • select disk 0
  • select volume 1
  • remove
  • select volume 3
  • remove
  • select volume 4
  • remove
  • select volume 5
  • remove
  • list volume

Again, the last command is just to verify that drive letter assignments have been removed from the volumes and that no volume is listed as RAW.