help with creating a batch script!!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sftmb
Posts: 3
Joined: 21 Jul 2010 12:44

help with creating a batch script!!

#1 Post by sftmb » 21 Jul 2010 13:02

hey guys, so i'm a noob to batch scripting and i'm trying to figure out how to write a script for work. basically what i need it to do is run through a loop of IP Addresses.

so for example if the ip list contained 127.1.1.1 and 127.1.1.2.

the script would take 127.1.1.1 and run the command systeminfo[.exe] [/s Computer [/u User [/p Password]]]

it would then have to insert the current ip it's working with into the computer field for that command. the user and password fields are the same for all machines. so the command would look something like this

systeminfo[.exe] [/s 127.1.1.1 [/u User [/p Password]]]

after running that command with the current ip of 127.1.1.1 i'd need it to stick the output to a file, say 127.1.1.1.txt

it would then move on to the next ip in the list, which is 127.1.1.2 and do the same thing.

i don't know if this is even possible but if anybody has suggestions i'd appreciate it! thanks!

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: help with creating a batch script!!

#2 Post by aGerman » 21 Jul 2010 13:44

What kind of "IP list" is it? Did you save the IP adresses in a file or come the adresses from another command?
Where do usernames and passwords come from? Or dont you need them?

Regards,
aGerman

sftmb
Posts: 3
Joined: 21 Jul 2010 12:44

Re: help with creating a batch script!!

#3 Post by sftmb » 21 Jul 2010 14:36

yeah, i have a .txt with a list of ip's in them. and the username and pass would be specified when i actually go to run the script. i just didn't include them in the post. lol

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: help with creating a batch script!!

#4 Post by aGerman » 21 Jul 2010 14:45

Try something like that:

Code: Select all

@echo off &setlocal
set list=IPList.txt
set User=testuser
set Password=testpass

for /f "usebackq" %%a in ("%list%") do (
  >>%%a.txt systeminfo /s %%a /u %User% /p %Password%
)


Regards
aGerman

sftmb
Posts: 3
Joined: 21 Jul 2010 12:44

Re: help with creating a batch script!!

#5 Post by sftmb » 21 Jul 2010 15:27

great! i can work with that. thanks alot for the quick response and help!

Post Reply