Here is a part of my batch...
for /f "delims=" %%i in ('C:\pathto\dig.exe www.example.com @8.8.8.8 +short') do set RIP=%%i
If %RIP%==93.184.216.119 (
ECHO - PASS >> results-file.txt
) else (
ECHO - FAIL >> results-file.txt
)
...this works fine - except, let's say the DNS server 8.8.8.8 is unavailable or broken (so for testing replace it with a bad IP) and then, normally from the command-line dig.exe will timeout and eventually return...
;; connection timed out; no servers could be reached
...followed by a return to the command prompt. So I would expect that string to get set in %RIP% and thus FAIL would be printed to the file, but what happens instead is dig.exe runs, timeout, and then cmd.exe just closes, and nothing gets written to the file, and the rest of the batch does not continue.
Any idea where I've gone wrong?