3
\$\begingroup\$

This code pings 1 time every IP while using TTL to identify if it's a Windows PC. If so, it outputs it. It's very slow, so is there any way to make it go faster (1-255 in 12 min)?

@echo off
echo running, it will take a long time to scan
(
  FOR /L %%N in (1 1 254) DO (
      FOR /f "tokens=1,3 delims=: " %%A IN ('ping -n 1 192.168.250.%%N ^| find "TTL=128"') DO ECHO %%B

  )
) >ip.txt

echo done
get_info.bat
\$\endgroup\$
  • \$\begingroup\$ What is in get_info.bat? \$\endgroup\$ – Quill Jan 14 '16 at 13:38
  • \$\begingroup\$ a bunch of Wmic commands, not so important, can post if interested \$\endgroup\$ – TmCookieMonster Jan 14 '16 at 13:40
2
\$\begingroup\$

You will have to reduce the timeout interval with the -w option (milliseconds), but I don't know what is the minimum timeout that still gives reliable results.

You could try

ping -w 500 -n 1 192.168.250.%%N
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Isnt the defult 1000. Would it improve it that much ? \$\endgroup\$ – TmCookieMonster Jan 16 '16 at 12:38
  • \$\begingroup\$ @TmCookieMonster - On my machine, the default is 4000 (4 seconds), so yes, a value of 500 makes a big difference. You certainly can set the value as low as you want, but I'm not a networking guy, so I don't know what a reasonable amount of time is to wait for a response. \$\endgroup\$ – dbenham Jan 16 '16 at 13:14
  • \$\begingroup\$ Every pc on the network is connectes via fiber, so 500 should be good enough. Well thanks for the input, im out travelig right now but i will test it on Wednesday next week. \$\endgroup\$ – TmCookieMonster Jan 16 '16 at 13:16
  • \$\begingroup\$ @TmCookieMonster - Well heck, try 100 :-) \$\endgroup\$ – dbenham Jan 16 '16 at 13:18
  • \$\begingroup\$ it worked like a charm ! went form 12 min to 2 min ! thanks \$\endgroup\$ – TmCookieMonster Jan 19 '16 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.