Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NT Batch File for Multiple IP Addresses

Status
Not open for further replies.

dwhite8

Vendor
Jun 11, 2001
3
0
0
US
How do I write an NT batch file for multiple IPs in different subnets? For example, I'm looking to ping everything with the 10.100.0.X, 1.X, and 5.X network and have the results in a text file? Is this possible? If so, how do I do it?

Thanks,
D
 
@echo off
:: You could put set outPutFile=%1 to accept an argument sent to the batch file
set outPutFile=c:\output.txt
set thirdOctetCount=0
set fourthOctetCount=0


:ThirdOctet
set fourthOctetCount=0
:FourthOctet
echo Now Pinging 192.168.%thirdOctetCount%.%fourthOctetCount%
ping 192.168.%thirdOctetCount%.%fourthOctetCount% -n 1 >> %outPutFile%
set /a fourthOctetCount=%fourthOctetCount%+1
if %fourthOctetCount%==256 goto EndFourthOctet
goto FourthOctet
:EndFourthOctet

set /a thirdOctetCount=%thirdOctetCount%+1

if %thirdOctetCount%==256 goto EndThirdOctet
goto ThirdOctet

:EndThirdOctet
Echo Done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top