So I recently had to do this AGAIN and was unable to find any good resource online on how to do it, other than "yeah just change permissions and delete it lol" or "format your drive, its dead"
My Xbox app wants to install on a drive that previously had some windows apps on it from an old install, It tells me to "set default location" and clear old data but then it throws an error! I don't want to format my drive, and changing permissions on its own are not enough to actually do this so what do you actually have to do?
Thankfully, when wrestling windows with this for the 4th time, I remembered to actually note down what I was doing to fix it, because every time I have to do it, google is useless.
Prerequisites:
WinDIRstat: https://windirstat.net/
Take Ownership Regkey: https://www.tenforums.com/tutorials/3841-add-take-ownership-context-menu-windows-10-a.html
Step 1: Find your "Windows Apps" Folder on the drive in question and rename it to "Windows Apps.old".
Step 2: Rightclick the file and "Take Ownership" and let that script run its course.
Step 3: Scan that drive with WinDIRstat, and delete all the subfolders and subfiles you can (the subfiles WILL throw an error but that's normal)
Step 4: Delete the "Windows Apps.old" folder in explorer. It will throw an error saying you cant do it. click cancel, refresh your explorer window and it should be gone.
Its stupid, and has been a problem for as long as I can remember. Basically an old windows install "Marks" this folder, so your new windows install doesn't have the rights to delete it, and you cant give yourself rights to just delete it either, you need to jump through stupid hoops.
Hopefully, this helps someone not have to format their drive, and more than likely I will stumble onto this in a few months when I need to try and delete this folder again after windows shits itself lol