15

I recently did a reset of my Windows 10 computer.

I have two drives connected:

  • C: an SSD, and
  • D: two regular HDDs forming a dynamic mirrored drive within Windows.

On the D: drive I had my old onedrive folder. d:\OneDrive after the reinstallation of Windows 10 it automatically made the OneDrive appear here: c:\users\xxx\Onedrive

I now want to remove my old onedrive folder on my D: drive. The problem is that windows won't allow me to delete, rename, copy or move that old folder. Giving me this error:

Error 0x8007018B: Access to the cloud file is denied.

Since it is a mirrored drive I can't easily but a portable unix-OS to modify it directly, so now I do not know what to do. That error message is not very documented on the web.

ehm
  • 704
  • 2
  • 10
  • 22
  • Unlink your account in OneDrive then re-add it specifying the proper location this time. Delete the folder on the C: afterwards. – Appleoddity Jun 23 '18 at 00:06
  • @Appleoddity that's not the problem. How can I delete the old folder on D: ? – ehm Jun 23 '18 at 10:04

3 Answers3

14

I was able to get rid of my old OneDrive folder by opening Powershell(admin). Then going to parent directory and using the command

Remove-Item "OneDrive folder name" -Recurse -Force

To open Powershell, press the Window key and X

Blackwood
  • 3,123
  • 11
  • 23
  • 32
  • 1
    This worked perfectly for me. – Sylaan K'daar Dec 02 '18 at 21:21
  • Worked for me. Much appreciated. – FirasR Jan 09 '19 at 16:04
  • 5
    I had high hopes this would work for me too. When I tried it I got the error: **Access to the cloud file is denied**. Maybe a newer version of Windows or OneDrive no longer allows this method of deleting. I'll keep looking for another way. – Matthew MacFarland Jul 28 '20 at 15:29
  • Did you ever find one? Something has definitely changed in OneDrive or PowerShell. You're unable to use Remove-Item "Folder" -Force with files on demand. Pretty sure this used to work... – munrobasher Nov 18 '20 at 22:08
  • 1
    Cmd's `rmdir /S` worked for me when PowerShell gave the cloud file error. Some say PowerShell works by doing `Get-Item` on folder then calling `.Delete()` on the result. [Apparently](https://answers.microsoft.com/en-us/windows/forum/all/how-do-you-delete-reparse-point-flags-from/079595f3-bb0e-4d78-b27f-4bd941a838c8) the cloud file error can also be caused by switching off Files On-Demand if/when OneDrive fails to remove reparse point flag from folders. – Vimes Dec 10 '21 at 00:16
7

You need to disable first “Files-On-Demand” feature in OneDrive:

  1. Right-click OneDrive in the System Tray Click the menu icon -> Settings -> Settings tab -> “Files-On-Demand” section -> disable the “Save space and download files as you use them” option
  2. Now run Remove-Item .\Your_Folder_Name\ -Force

If still doesn't work and you face the error:

Remove-Item : There is a mismatch between the tag specified in the request and the tag present in the reparse point

then do this:

  1. run Dism /Online /Cleanup-Image /CheckHealth
  2. run Dism /Online /Cleanup-Image /ScanHealth
  3. run Dism /Online /Cleanup-Image /RestoreHealth
  4. and now on an elevated prompt run cmd /c rmdir /s /q C:\Users\Your_User_Name\Your_Folder_Name

PowerShell cannot handle broken symlink, use the hammer, use CMD.

  • This should be the accepted answer. It is the only one that correctly identifies the real problem (On-Demand files setting) and the proper solution. Force deleting on boot or through admin-console may leave inaccessible files in your OneDrive storage in the cloud if you don't turn of the On-Demand feature first. – Tonny Dec 15 '20 at 12:25
  • 1
    It is indeed the correct answer although why Microsoft are unable to fix it is perplexing... – munrobasher Feb 25 '21 at 16:59
  • 2
    This solution worked for me. – Rajaraman Subramanian Mar 02 '21 at 08:57
  • Additionally needed sfc and chkdsk: https://superuser.com/a/1734952/164429 – Tyler Montney Aug 31 '22 at 22:24
1

I managed to delete the folder by using boot deleter. I just had to make sure to give it admin privileges by right clicking the .exe -> properties -> compatability -> run as admin.

ehm
  • 704
  • 2
  • 10
  • 22