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?
@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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.