Solved

batch file for syntax problem windows 7 cmd prompt

Posted on 2014-02-14
4
969 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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

636 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