Solved For loop cacls permission editing

Microsoft Visual studio professional 201...
November 27, 2012 at 06:18:27
Specs: Windows 7, 4.17Ghz 8GB ram
How would I change every folder in a drive that says "Design" to only have read permissions for "Domain Users" group?

I have messed around with some for loops using cacls but cant seem to get it working quite right.

See More: For loop cacls permission editing

Report •

January 14, 2013 at 07:42:58
Hey Rocky3598,

I can help you with this if you still need it. We can use findstr on dir output to create a list of folders containing the word "design". Then we can use a for loop on that list to cacls the permissions. Let me know if you still want help.

Report •

January 14, 2013 at 07:53:43
Yes i would still like help. I also thought I would need to use a for loop but im not quite sure how to make it search through directories and change permissions.

Report •

January 14, 2013 at 08:22:23
✔ Best Answer

Ok here's a start... the cacls command is incomplete though. Do you already have the cacls command you want?

@echo off

REM removing old tmp files
del /q dir.tmp
del /q dirclean.tmp

REM create list of folders containing keyword "design"
dir /ad /b > dir.tmp
findstr /l /i "design" dir.tmp > dirclean.tmp

REM loop through list and apply permissions
for /i "tokens=*" %%a in (dirclean.tmp) do (
cacls %%a ....


Report •

Related Solutions

January 14, 2013 at 09:13:24
I like that! Is there anyway to make it search through sub directories also?

Possibly using tree?

Report •

January 14, 2013 at 09:22:20
Yes. If we add a /s to the first dir command, it will search through the directory it is running in, and all subdirectories as well. If we used tree, I would have to create a module to clean up all of the tree structure lines.

Report •

January 14, 2013 at 09:27:06
Ok thats what I was also thinking i just wanted to make sure that it would work with the exact path now.

Thank you for the help it has made this process way faster

Report •

January 14, 2013 at 09:32:17
No problem. Glad I could help.

Report •

Ask Question