Computing.Net > Forums > Programming > Batch file loop

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file loop

Reply to Message Icon

Name: d4rkcell
Date: March 24, 2009 at 11:33:06 Pacific
OS: Windows XP SP3
Subcategory: Batch
Comment:

Hello,

I have a small problem and need some help. We need to quickly find the MAC addresses of machines and all we have is the hostname.

We have been using the getmac /s \\computername command to get the mac address of a single hostname.

I have a text file which has lots of hostnames in it (150) one per line e.g.

hostname1
hostname2
hostname3

I am using the following command

getmac /s hostname1 /u domain\user /p password /fo csv /nh >> ThisFile.txt

My question is, is there anyway to loop through the file using each line of the file as the hostname for example in the form of a variable. I'm not too hot with batch scripting so not great with loops any help would be much appreciated!!

TIA
d4rkcell



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: March 24, 2009 at 13:08:26 Pacific
Reply:

Non-Command Script version:

FOR /F %a IN (SomeTextFile) DO getmac /s %a /u domain\user /p password /fo csv /nh >> ThisFile.txt
SomeTextFile's name cannot contain spaces.

0

Response Number 2
Name: d4rkcell
Date: March 25, 2009 at 01:03:28 Pacific
Reply:

Thank you this has me on the right track :-)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file loop

Batch File Looping Escape: www.computing.net/answers/programming/batch-file-looping-escape/15452.html

Batch File Loop - Help www.computing.net/answers/programming/batch-file-loop-help/15019.html

Batch file loop help www.computing.net/answers/programming/batch-file-loop-help/13017.html