14

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?

1 Answer 1

30

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
5
  • 2
    I get an error saying that 'Y' cannot be used with option '/D'
    – Manticore
    Apr 11, 2018 at 14:22
  • 1
    @Manticore You didn't provide your full example command, nor any detail about the environment in which you ran it. I did just copy/paste the takeown line from my answer and it still works, nearly four years later, on Windows 10 1709.
    – jscott
    Apr 11, 2018 at 14:45
  • @jscott I am just saying what happened to me. Windows 10 1709, too.I copy-pasted it (carefully), ran the command and got back the message. I managed to solve my problem with takeown though. Just had to use different options.
    – Manticore
    Apr 13, 2018 at 11:25
  • 8
    @Manticore The '/D' option needs a localized input, so for a german Windows install use takeown /F D:\files /R /A /D J (J instead of Y) instead.
    – Paul
    Mar 4, 2019 at 12:03
  • @Manticore I got your issue too, this is explained in the help output (/?).
    – Amessihel
    Jan 7, 2021 at 11:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .