Avatar of VortexAdmin
VortexAdmin
Flag for United States of America

asked on 

Batch file command to build list of valid IPs

I need a line of code necessary to iterate through all possible IPs on my subnet and build a list of IP addresses that respond to a ping command.  Something along the lines of:

FOR /L %%a IN (1, 1, 254) DO PING -n 1 -w 60 192.168.1.%%a | find /i "Reply" >> IPs.txt

However I only want it to log the IP address itself, not any of the other information.  I think I need to incorporate a
findstr /i "from" command or something in there but don't know how to go about it and grab the text next to it.  I would also like to know if it's possible to append future runnings of the command (>> IPs.txt) to the existing list but not repeat any of the IPs.  Is it possible to check the list first then not add that IP if it's already in there?  

Thanks.

Microsoft DOSProgramming

Avatar of undefined
Last Comment
VortexAdmin

8/22/2022 - Mon