Monday, July 16, 2012

Windows script - For loop

I had a requirement where I was supposed to get nslookup output from entire subnet. If it were Unix, it was easy for me :) but I am not much into windows therefore I am writing it here so that one day again I will re-use this code:

c:/> type nslookup_using_for_loop.bat 
@echo off

for /L %%N IN (10,1,254) do (
echo 192.168.1.%%N
nslookup 192.168.1.%%N
echo **********************************************

Basically, the above script will run nslookup on all IPs ranging between and Enjoy!!! :)

No comments: