Recursive reset file permissions on Windows
There is a big, complex directory structure on a relative big NTFS partition. Somebody managed to put very bad security privileges onto it - there are directories with randomly given/denied permissions, etc. I already run into permission bugs multiple times, and I found insecure permission settings multiple times (for example, write permissions for "Everyone", or false owners).
I don't have time to check everything by hand (it is big).
But luckily, my wishes are very simple. The most common: read/write/execute on anything for me, and maybe read for Everyone.
Is it possible to somehow
- remove all security data from a directory
- and giving my (simple) wishes to overwrite everything there?
On Unix, I used a chown -R ...
, chmod -R ...
command sequence. What is its equivalent on Windows?
Solution 1:
NTFS is a bit more fine-grained than RWX, so for this example, I'm just resetting the ACLs to default. If you have a specific collection of ACEs, please add them to your question. Also, if the drive permissions themselves are mangled, we'd need to fix those as well.
Assuming the tree is rooted at D:\files:
REM Make local administrators group owner.
takeown /F D:\files /R /A /D Y
REM Reset ACLs to defaults.
icacls D:\files /reset /T /C /L /Q