Is there any way I can get it to record a failed ping without having to get rid of: " | FIND "TTL=""?
No, at least not using Microsoft's stock
Here's some documentation for
find which on the client side applies to Windows Vista and Windows 8 that states, in part:
If you do not use /i, find searches for exactly what you specify for String.
Since you can only specify one String to search for, there is no direct way to do what you are trying to do.
You can, however, do it in a slightly roundabout way: redirect the output of
ping to a temporary file, and run
find twice on that file:
ping -n %var1% 127.0.0.1 > Test.tmp
FIND "TTL=" Test.tmp > Test.txt
FIND "Request timed out." Test.tmp >> Test.txt
Or you can use a tool that supports searching for multiple distinct strings, such as GNU
grep (which is available for Win32). An alternative approach pointed out in a comment by and31415 is to use
findstr instead, which is available in Windows 2000 and newer:
ping -n %var1% 127.0.0.1 | findstr /c:"TTL=" /c:"Request timed out."
Obviously, since both of these operate by looking at the native language output of
ping they will have problems with non-English locales.
It's worth remembering that
find originated in DOS 2.0. That was the same version of DOS that introduced directories, and hard disk support (DOS 1.x only supported using floppy disks for persistent storage, and lacked the concept of directories). Since backwards compatibility is something that Microsoft still takes quite seriously, they cannot easily change how
find treats the String parameter, and back in the DOS 2.0 days, both memory and processing speed were at huge premiums. It appears that the
find in DOS 2.x didn't even support case insensitive searching (added later with the
/I switch). It is an arcane utility, really, surviving much because it cannot trivially be replaced with something different.