SOLVED - see next reply!

This is probably too niche to ask here, but:

#Windows11 users - have you ever run across a file or directory that you can't access, and can't change permissions on, as administrator? If so, how do you fix it?

I'm trying to transfer files from an old laptop to a new laptop using rsync in cygwin, and I used my standard rsync -avz approach, which works great in Linux, but apparently totally bollixes up #Windows.

The directory it created looks like it has correct permissions, but when I try to open it, access is denied. I tried the below suggestions from various Internet forums, and they claimed success but didn't solve the problem - and the robocopy actually made a *second* cursed directory!

C:\Users\Lisa\Backups>cd X250

C:\Users\Lisa\Backups\X250>cd Personal
Access is denied.

C:\Users\Lisa\Backups\X250>takeown -F Personal

SUCCESS: The file (or folder): "C:\Users\Lisa\Backups\X250\Personal" now owned by user "LISA-T14S\Lisa".

C:\Users\Lisa\Backups\X250>icacls Personal /grant Lisa:(oi)(ci)f /inheritance:e
processed file: Personal
Successfully processed 1 files; Failed processing 0 files

C:\Users\Lisa\Backups\X250>cd Personal
Access is denied.

C:\Users\Lisa\Backups\X250>robocopy Personal Personal-fix /COPYALL /SECFIX /SEC

[stuff happens here...]

C:\Users\Lisa\Backups\X250>cd Personal-fix
Access is denied.

I'm going to try the rsync again without preserving permissions ( -vzrlt ) but I'd love to be able to access - or at least delete - these directories!!

Y'all, this was a *journey*. @mikejs reminded me to check the advanced permissions, and *of course* there was a Deny on my local user (whyyyyyyyyyy?), and *of course* I couldn't remove it even after launching file explorer with administrator rights...

So I ended up enabling the built-in Adminstrator account (net user administrator /active:yes), switching to that user, and trying again - and it *still* wouldn't let me change the permissions! 🤬​

What finally did work was taking Administrator ownership of the files:
takeown /F C:\Users\Lisa\Backups\X250\Personal
takeown /F C:\Users\Lisa\Backups\X250\Personal /r /d y
(this hung on some DLL for an ancient NIC installer, which it claimed didn't exist even though *it was reporting to me that it was trying to act on it*, WTF) - solved that by blowing away the entire installer directory, because OMG I need to decruftify all this ancient data)

and then granting the Administrator access:
icacls C:\Users\Lisa\Backups\X250\Personal /grant Administrators:F
icacls C:\Users\Lisa\Backups\X250\Personal /grant Administrators:F
/t
(which touched *every single individual file* and hung on a couple of ridiculously-long Unix filenames from a phone SD card backup, which I solved by renaming the files, but then it had to start over from the beginning each time, because of course it did)

And *then* I could finally change the Deny to Allow, apply it to all child objects, apply the changes, and change the owner back to my local user.

If you have read this far, my apologies for writing a book on your feed - my sole purpose it dropping all this here is that I just opted in to search, so maybe someday this will help some poor bastard who gets the same error. I expect to have to sysadmin my Linux boxen - not my personal laptop!!

#Windows #Windows11 #permissions #shootmenow