Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to change permissions on a file/folder through the command line. I can do this manually by:

  • Right-click on any file/folder
  • Properties
  • Security (tab)
  • Edit...
  • Add...
  • Enter the object names to select: Users
  • OK

How do I do this using a command line.

Edit:

This works

icacls "C:\folder1\folder2\file.txt" /grant:r Users:F

The problem is I want to select the parent folder and for it to effect all files.

Doesn't work:

icacls "C:\folder" /grant:r Users:(OI)(CI)F

Is it because icacls can't refer to a folder??

share|improve this question
    
icacls works just fine on folders. In fact you should avoid setting permissions on files, since some stupid applications will wipe them out when a save happens. – Zoredache Aug 7 '13 at 7:02
    
The file only has SYSTEM and Administrators in the permission group. I think this is what is causing the problem. – user243868 Aug 7 '13 at 7:14
    
Don't edit your question to add the solution. Post it as an answer separately – Canadian Luke Aug 14 '13 at 4:55
    
I can't I am too new. – user243868 Aug 14 '13 at 5:13

I think icacls is what are you looking for, e.g.:

D:\>icacls D:\path\to\directory /grant administrators:F /t

Take a look: http://technet.microsoft.com/de-de/library/cc753525%28v=ws.10%29.aspx

share|improve this answer
    
icacls is not working on these particular files. It only works if I specify the directory of the file, rather than anything in the folder. – user243868 Aug 7 '13 at 6:31
    
If it isn't working, please tell us exactly what error message you are getting. – Zoredache Aug 7 '13 at 7:03
    
There is no error. It says Successfully processed 1 file. But when I go in to check, I get two very different results. – user243868 Aug 7 '13 at 7:23
up vote 0 down vote accepted

In a batch (.bat). This is used for stubborn files that refuse to inherit the folder permissions. For command line only one %

FOR /R "C:\Folder" %%G IN (*.*) DO icalcs %% /grant:r Everyone:F
share|improve this answer

You must log in to answer this question.

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