Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Commands

Posted on 2012-09-02
10
Medium Priority
?
375 Views
Last Modified: 2012-09-07
I want to how to loop with FOR commands:

Say for example I have list of users in a file called users.txt. I need to find the properties of each users in the users.txt.

net user <username> will give the properties of a username. How to loop so that I can get the properties of each users in Users.txt file

Thanks
0
Comment
Question by:jmohan0302
8 Comments
 
LVL 97

Accepted Solution

by:
Lee W, MVP earned 668 total points
ID: 38359979
Have you typed "for /?" or reviewed any of the questions here?

It's very simple:

FOR /f %a in (users.txt) do @net user %a
0
 
LVL 14

Assisted Solution

by:theruck
theruck earned 668 total points
ID: 38359986
for /F %A in (myfile.txt) do net user %A

if you are going to use it as part of a script then you need to use double %

for /F %%A in (myfile.txt) do net user %%A
0
 
LVL 39

Assisted Solution

by:Krzysztof Pytko
Krzysztof Pytko earned 664 total points
ID: 38360013
Just only to add, out of discussion

Follow leew'a syntax which does all you need but at the end add redirection to file. It would be much more easy to identify those properties for users

FOR /f %a in (users.txt) do @net user %a >%a.txt

Open in new window


when you run that all user properties will be redirected to a text file named from user name.

Regards,
Krzysztof
0
Industry Leaders: 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!

 
LVL 1

Expert Comment

by:sipl
ID: 38360036
for user in `cat users.txt`
do
          net user $user
done
0
 

Author Comment

by:jmohan0302
ID: 38361274
Resolved
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 38361581
Could you explain why I was not awarded a portion of the points considering I posted first with the exact same answer (in part) as the TheRuck and iSiek's answer built on (even referenced) mine?
0
 
LVL 14

Expert Comment

by:theruck
ID: 38361756
i guess for your attitude in your post :)
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 38361891
So I shouldn't explain how someone might find an answer better or more importantly faster by simply typing for /? ?

I believe in TEACHING not just giving an answer.  Sorry you disagree.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hallo! I guess almost every Windows Administrator must have got stumped with this question "Where does WINDOWS store a users cached credentials? Every user who had once logged onto a Server/Desktop while it was connected to the domain could sti…
INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

864 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