DOS question: running a command on folders AND subfolders

2500
3
Jump to solution
12-29-2015 07:12 PM
AlexZhuk
Occasional Contributor III

Hi, I need to update security settings (i.e. grant the Modify permission to the GIS users group) on ALL files\folders\subflders within a mother-folder. There are many-many of them inside. I'm on Win 2008 Server R2.

So I run this command:

>icacls  motherFolder\*   /grant  myCoDomain\GISusersGrp:(M)

The command returns successful message that it changed the all the files  (A1, A2, ...) and all the folders (F1, F2, ...) in the first level only. No subfolders (SF1) and no level-B files are mentioned and affected. And, even F1 and F2, folders are called "successful", their security setting have NOT been changed! Why? Unfortunately, ICACLS Help is not very helpful

Explicit command on a folder doesn't work either:

>icacls  motherFolder\F1   /grant  myCoDomain\GISusersGrp:(M)

dir.png

0 Kudos
1 Solution

Accepted Solutions
AlexZhuk
Occasional Contributor III

Adding two options for Objects and containers solved the 99% of the issue. Now everything got updated , except the files in the top level.

So I had to resort to running the command twice:

>icacls  motherFolder\*   /grant  myCoDomain\GISusersGrp:(M)

>icacls  motherFolder\*   /grant  myCoDomain\GISusersGrp:(OI)(CI)(M)

and that did the trick!

Thank you and a happy New 2016 Year!

View solution in original post

0 Kudos
3 Replies
TedKowal
Occasional Contributor III

/T

Indicates that this operation is performed on all matching files/directories below the directories specified in the name.

If memory serves me, I believe there is a bug for traversing sub-directories the inheritance flag must be set for the traversal to work.

This source may give you some other ideas and examples:  Windows command line icacls command help

0 Kudos
AlexZhuk
Occasional Contributor III

Wow! Great help. It got me halfway forward. Thanks.

Now the files in all sub-directories got the security settings right. But the folders themselves didn't get affected. So the users still can't create new files in them, even though they can modify the existing files that have been updated by this script.

Still need to research further. And yes, I was aware in some bug in ICACLS, but thought I may escape it.

0 Kudos
AlexZhuk
Occasional Contributor III

Adding two options for Objects and containers solved the 99% of the issue. Now everything got updated , except the files in the top level.

So I had to resort to running the command twice:

>icacls  motherFolder\*   /grant  myCoDomain\GISusersGrp:(M)

>icacls  motherFolder\*   /grant  myCoDomain\GISusersGrp:(OI)(CI)(M)

and that did the trick!

Thank you and a happy New 2016 Year!

0 Kudos