Solved

batch file for syntax problem windows 7 cmd prompt

Posted on 2014-02-14
4
954 Views
Last Modified: 2014-02-14
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.
0
Comment
Question by:YMartin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Andrej Pirman
ID: 39860230
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"
)
0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39860231
If you use the /d switch, then inside the parentheses is a set of one or more files.  If you want to run the command "dir /b" and work on its output, then you need to use the /f switch instead.
for /f %%a in ('dir /b *') do echo %%a

Open in new window

0
 
LVL 18

Expert Comment

by:Andrej Pirman
ID: 39860237
Also, peek at this page might give you some ideas:
http://www.robvanderwoude.com/ntadmincommands.php#Cmd09
0
 
LVL 1

Author Closing Comment

by:YMartin
ID: 39860257
That was it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TLS 1.0 & Windows 7 - How to disable? 16 237
installing fonts 5 41
DOS Script 4 35
Window 10 Local Account password no longer works and cannot recover 5 23
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question