Search code examples
windowscommand-linepermissions

Windows command line change folder permission


The scenario is as follows:

  • A program that's executed with admin rights creates a folder, "C:\my folder".
  • In cmd, I want to grant full control of this folder to everyone.

How can I do it? I tried

cacls "C:\my folder" /E /P "*S-1-1-0":F

and didn't work. I also tried

cacls "C:\my folder" /E /P "Everyone":F

and didn't work. Yet,

cacls "C:\my folder" /E /P "Todos":F

did work -- where "Todos" stands for "Everyone" in a Spanish installation of Windows. How can I accomplish this no matter what language Windows was installed with?

NOTE: I know cacls is supposed to be deprecated in favour of icacls. I don't mind. Please, don't waste your time pointing it out, unless there is a way to achieve this in icacls.


Solution

  • In my own dispare, I finally managed to figure it out:
    icacls "C:\my folder" /GRANT *S-1-1-0:F
    This is funny: I figured it out by means of technet.microsoft.com, YET, THEIR OWN DOCUMENTATION IS WRONG!!!
    IN https://technet.microsoft.com/es-es/library/cc753525(v=ws.10).aspx they state you should use
    Icacls test2 GRANT *S-1-1-0:(d,wdac)
    when you should actually use
    Icacls test2 /GRANT *S-1-1-0:(d,wdac)