# Windows 7 Command Line Add Group “Users” To File

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...
• 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??

-
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
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

-
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

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

-