Link to home
Start Free TrialLog in
Avatar of YMartin
YMartin

asked on

batch file for syntax problem windows 7 cmd prompt

Having problems with a batch file which runs a command on each subfolder.  Googling has told me this should list each subfolder name.  It does not.  It lists 'dir' then '/b'.  It is treating the array as literal text rather than the output of the dir /b * command.

for /d %%a in ('dir /b *') do echo %%a || icacls %%! | find /i "domain users"

I am trying to run icacls on each folder and search the output for "domain users" to see what the permissions are for domain users.
Avatar of Andrej Pirman
Andrej Pirman
Flag of Slovenia image

I suggest you do it in two steps:

dir c:\some_folder /A:D /D /B>userlist.txt
FOR /f %%D IN (userlist.txt) DO (
ECHO %%a || icacls %%! | find /i "domain users"
)
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, peek at this page might give you some ideas:
http://www.robvanderwoude.com/ntadmincommands.php#Cmd09
Avatar of YMartin
YMartin

ASKER

That was it.