Slightly updated the answer the /D Y
part will recursively accept taking ownership when directory listing is denied in the permissions:
To fix really broken permissions, the best is to run these two commands one after the other:
takeown /F /D Y "C:\path\to\folder" /R icacls "C:\path\to\folder" /reset /T
The first one will give you ownership of all the files, however that might not be enough, for example if all the files have the read/write/exec permissions set to “deny”. You own the files but still cannot do anything with them.
In that case, run the second command, which will fix the broken permissions.
via: permissions – recursively change owner windows 7 – Super User
–jeroen
Filed under: Batch-Files, Development, Power User, Scripting, Software Development, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows 9, Windows Development, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Vista, Windows XP
