Unnecessarily complicated
Sure, you could do ipconfig /all, look for the DNS Servers line and type it after ping -t. Sure, if you’re a loser! You might as well just wait on your ISP’s level-1 tech support line for two or three hours, just to find out that your DSL is down either at the DSLAM or the POP.
Instead, try this:for /F "tokens=2 delims=:" %a in ('ipconfig /all ^| find /i "DNS Servers"') do ping -t %a
(That should be all one line.)
Expanded:
ipconfig /allprints the current TCP/IP configuration.^|pipes the output of the previous command to the next command. See the linked article for why the caret is required before the pipe.find /isearches the following quoted text, case-insensitive."DNS Servers"is from the output ofipconfig /all.for /F "tokens=2 delims=:" %a intakes the output from the previous elements (typically something likeDNS Servers . . . . . . . . . . . : 64.81.79.2), parses it into tokens delimited by a colon, selects the second token and places the result into the named variable%a.dois the “execute” part offor; whatever command follows is run with the parsed parameters.ping -tsends ICMP ECHO requests to the target IP address; the-tparameter causes the pings to continue until interrupted with Ctrl-C.
All clear? Isn’t that better? I’m just saying.
By the way, this is not meant to impugn Speakeasy’s most excellent tech support people. Yes, my DSL has flakier than Marie Callender‘s finest crust for the past few days, but it’s not Speakeasy’s fault and they’re managing the diagnostic/repair process through Covad and AT&T.;
Oh, and if you want to put this in a batch file, you’ll need to double the percent signs in front of the variable. Like this:for /F "tokens=2 delims=:" %%a in ('ipconfig /all ^| find /i "DNS Servers"') do ping -t %%a
