# Batch file experts?



## beorning (Apr 14, 2006)

I need to write a batch script for my windows server class that runs an nslookup against a specified target 50 times, with a time stamp at the beginning and end of each series and a DNS flush between each lookup.

something like :

time /t

nslookup google.com 
ipconfig /flushdns
(times 50)

time /t

Anyone know of a way to repeat the nslookup and ipdconfig comands 50 times without having to copy and paste the commands for each time in a batch file?

I realize that scripting it in Perl or some other language would probably be slicker, but I really have zero scripting skill at this point and need to write whatever script I use myself. A batch file meets the minimum project requirements.


----------



## OntarioMan (Feb 11, 2007)

Use a loop with a counter variable. Something like :

set N=0 << your counter variable
set X=50 << your maximum variable
:LOOP
set N+=1 << increase N by 1
if N gtr X goto :eof << if N > X, the end
put your lookup and flush stuff here
goto :LOOP

I can't remember the exact commands, but they should be similar.




beorning said:


> I need to write a batch script for my windows server class that runs an nslookup against a specified target 50 times, with a time stamp at the beginning and end of each series and a DNS flush between each lookup.
> 
> something like :
> 
> ...


----------



## Nevada (Sep 9, 2004)

That's the "FOR" loop command.

http://www.robvanderwoude.com/for.html


----------



## beorning (Apr 14, 2006)

Thanks, Nevada. That did the trick.


----------

