[German]It seems that a couple of Windows 10 users are facing system restore error 0x80070091. I’ve blogged about that issue within my German blog, and it seems that my solution works. Here are a few hints for my English readers how to analyze and solve this issue.
I found several forum posts from December 2016 and January 2017 mentions this error code (see here, here, here, here, here for Windows 10, and here for Windows 8). But I came across this error the first time within a German Microsoft Answers forum post. A user describes the the error message as follows:
Version 1607 (Build 14986.1001)
I’m using system restore to create a restore point. Then I tried to revert back to this system restore point. After a while I got an error 0x80070091.
System Restore did not complete successfully. Your computer’s system files and settings wern not changed.
Details: System Restore failed whil restoring the directory from the restore point.
So system restore failed with error 0x80070091 due to something broken in AppxStaging. Below is also a screenshot detailing this error.
Error code 0x80070091 stands for ERROR_DIR_NOT_EMPTY (The directory isn’t empty). Obviously something is broken in folder
so the AppxStaging function drops an error and refuse to rewrite the folder from system restore.
Windows 8 and later versions are using folder %ProgramFiles%\WindowsApps to store preinstalled apps Also Windows 10 is using this folder to store preinstalled apps.
The screenshot shown above list the subfolders used to store apps. There are also folders named Deleted or DeletedAllUserPackages or MovedPackages containing also entries. I guess, something during deleting, updating or moving an app went wrong, and a folder isn’t left empty. Then AppxStaging isn’t able to restore the app folder from system restore and drops an error. Maybe third party tools like antivirus software is blocking, but I don’t know for sure. The best, what we can do: Try to proceed the following steps – beginning with simple approaches.
Feedback from my German reader of this blog post Windows 10 Version 1607: Unbekannter Fehler 0x80070091 confirms, that some solution works.
Addendum: How to list the WindowsApps folder as Administrator
Some user comments I received from my German blog post are indicating, that the folder
contains some redirections (subfolders VFS with NTFS links) and could not be deleted. Virtual File System is used by App-V to redirect folders for instance. Perhaps something went wrong during updating apps. Robert Aldwinckle has suggested at Microsoft Answers forum a solution to list the folder’s content without changing the permissions or tampering with TrustedInstaller rights. Here are the steps to proceed.
- Press Windows+X and select Command prompt (Admin), and confirm UAC (see Windows 10: Open command prompt window as administrator).
- Enter PowerShell in command prompt window and press the enter key .
- If the PowerShell command prompt PS C:\WINDOWS\system32> is visible, use the commands below.
The command below changes the path to folder WindowsApps.
Then use the following command to enlist all sub-folders and its content via PowerShell and store the results within clipboard.
(LS -Re -Fi * -Fo -Ea:Inquire).FullName | clip
Then launch notepad using the PowerShell command notepad and insert the clipboard content pressing Strg+V. Afterward you can inspect all sub-folders within Windows editor. Search for VFS sub-folders for instance. My suspicion is, that some re-direction could be the cause for the system restore issue.
Fix #1: Try to remove third party tools and check your system
If a third party antivirus software causes this issue, the most simple approach is, to uninstall this AV software and use a vendor’s clean tool to remove also files and settings remaining from uninstalling.
Reboot Windows and check the system for damaged system components, using the advices given within my blog post Check and repair Windows system files and component store. Also try to do a disk check for Windows drive (right click Windows drive, select Properties and use the Tools tab to start a disk scan).
Fix #2: Try system restore from Windows PE
If third party tools blocks system restore, maybe it helps to execute system restore from Windows PE. Just click the On/off button in start menu and select the Restart command while the Shift key has been pressed.
If the Windows PE shows the page Chose an option click Troubleshoot and go to Advanced options in the next page.
Within the Advanced options page select the System Restore tile and let Windows PE try to execute the system restore (see also Windows 10 hangs with error code 0xc0000034 or Windows 10: Defender Offline Scan boot loop – Part 2).
If it goes well, system restore is successful and your machine will revert to the selected restore point.
I read also, that renaming folder WindowsApps is possible within Windows PE (in command prompt window) without further hassle. The other solution is discussed below at Fix #5.
Fix #3: Synchronize Computer settings
There is another proposal how to fix system restore error 0x80070091 with synchronizing Windows settings. I found it within this MS Answers forum post.
- Go to Settings app (via start menu), click on Accounts
- Select Sync your settings
- Turn off Sync settings
Then reboot Windows and check whether system restore is back in operation again. But I fear, it won’t help.
Fix #4: Uninstall Windows Apps
My idea was, to clean folder %ProgramFiles%\WindowsApps, because it is named as a root cause. One attempt could be to go to Settings app, select System – Apps & Features and try to uninstall all apps. But Windows 10 won’t let you uninstall all pre-installed apps. So this attempt will fail.
It’s possible, to use the approach discussed within this SuperUser thread, and remove all apps via PowerShell. But that probably didn’t help, if the app causing the system restore error has been partly removed. Maybe disk cleaning (via Windows drive’s property page) helps, but I’m skeptical.
Fix #5: Rename/clean WindowsApps folder
If you have proceeded the steps given above, and your are not successful at all, you run out of “simple click solutions”. Then it’s time for a more radical approach. We are going now to clean up the folder %ProgramFiles%\WindowsApps that is causing trouble.
Warning: You are at your own risk, and accessing this protected folder is a bit tricky – but feedback from my German blog readers say it works.
The biggest problem is to access the folder %ProgramFiles%\WindowsApps, because this folder is owned by TrustedInstaller and is protected in a special manner. So you are not even able to open this folder within Windows Explorer.
You can try to obtain the ownership of this folder, following the advices given here How to Get Access to WindowsApps Folder in Windows 10 or here or here. But I won’t recommend this solution, due to the risk of unknown side effects – and because I have a more smart solution.
This blog post How to clean up the app folder in Windows 8.1 and 10 (delete app´s)! discusses how to use file manager Q-DIR to access the folder %ProgramFiles%\WindowsApps. I’ve used another approach: I executed the third party file manager Explorer++ portable within the Trusted Installer’s context. Trusted Intaller has full access rights to %ProgramFiles%\WindowsApps.
The steps, how to launch Explorer++ portable with Trusted Installer credentials has been discussed within my blog post Windows 10: Execute programs as System/ Trusted Installer. Using this approach, enables me to create a copy of WindowsApps, inspect sub folders and subsequently delete entries.
- In a first approach just rename the folder WindowsApps to WindowsApps.old, using the approach outlined above.
- Then reboot your Windows 10 machine and try to execute system restore and let it restore a previous state.
Some users of my German blog post confirmed, that this solution worked. One user mentioned, that some VFS subfolders contains NTFS links (for folder redirections) and couln’t be deleted, but the WindowsApps folder was renameable. System restore set the machine to a previous state, and all apps are also back. If that didn’t cure the isse, your are able, to re-rename WindowsApps.old back to WindowsApps and try other fixes.
In case, you are not able to use process hacker and my solution above, or in case some files are locked, try to boot into Windows PE (see Fix #2) and go to the command prompt windows. Then try to enter the following commands (press enter key to execute each command):
cd ‘C:\Program Files’
takeown /f WindowsApps /r /d Y
icacls WindowsApps /grant “%USERDOMAIN%\%USERNAME%”:(F) /t
attrib WindowsApps -h
rename WindowsApps WindowsApps.old
Note: I assumed, that logical drive C: is the Windows partition. Please check, if that’s true – sometimes Windows drive is D: (tip: you can launch notepad.exe and select File – Open to use Open dialog as a mini file manager). Drive X: is wrong, because this is Windows PE running in a RAM disk. I’ve added the attrib command due to GregoryLivingston’s MS answers hint, that rename fails, if the folder is hidden. If the rename command fails, or if you like to delete the folder, use the command:
rd /s WindowsApps
The rd command deletes the WindowsApps folder with all sub folders. It’s confirmed within this forum post, that the command sequence has worked. Then close command prompt windows and try system restore again. It should work now (if not, try a reboot first).
If fix #5 fails also, it’s time to reset your Windows 10 to factory settings, using the Settings app. Hope, the hints given above helps to cure Windows 10 system restore error 0x80070091. Comments and further suggestions are welcome. If it worked for you, please let us know.
PostScript: There are indications, that the error could be related to January 2017 update for Windows 10. I’ve had a test machine with no other software installed, that fails with system restore error 0x80070091. But uninstalling KB3213986 won’t cure this (see my comment within the [German] blog post) – you need to process the instruction of fix #5.
Addendum: Well, we have nailed it down to KB3213986 (see Windows 10 Update KB3213986 kills system restore).
Addendum 2: See my new findings here Windows 10: News about System restore error 0x80070091.
Windows: How to decode update 0x8024…. errors
Windows 10: Open command prompt window as administrator
Check and repair Windows system files and component store
How to fix Windows-Setup Hard Disk locked error
Windows 10: Defender Offline Scan boot loop – Part 2
Process Monitor: How to enable Windows 10 boot logging
Windows 10: Execute programs as System/TrustedInstaller
Cookies helps to fund this blog: Cookie settings