Search code examples
batch-filewindows-8permissionscaclsicacls

icacls Deny Delete for Everyone Not Working


I am trying to deny all users from being able to delete a file. I'd like any user to be able to read or exeucute the file, but not modify or delete it. However, after I use the following code via the command prompt, no one can even access the file in the first place!

icacls pic.jpg /deny Everyone:(D)

I've tried variations of granting some permissions and denying others to no avail. How can I accomplish this (on Windows 7/8)?


Solution

  • To protect a file you must use:

    icacls pic.jpg /deny Everyone:(DE)
    

    to protect a folder with it's content use:

    icacls pics /deny Everyone:(OI)(CI)(DE,DC)
    

    D is an combination of different access rights, if you want to grant the right to delete files.

    To get this language independent use *S-1-1-0 instead of Everyone.


    (OI)= Object Inheritance (CI)= Container Inheritance