windows - How do I ping the default gateway without specifying the IP address? -



windows - How do I ping the default gateway without specifying the IP address? -

i'm trying write batch file tests network connectivity pinging default gateway of given network. however, want automated process logs results text file, i'd able ping gateway on various networks, without having change/enter ip address.

is there generic term or command ping default gateway network you're connected to?

(i have commands output options etc.)

so far, have this....

@echo off goto :network1 :network1 ipconfig echo . set /p gateway=please come in gateway ip address (shown above): if /i "%gateway%" equ "exit" goto :exit if /i not "%gateway%" equ "exit" goto :network2 :network2 echo closing window abort connectivity test. echo . >> "c:\network test results %date:/=.%.txt" echo time: >> "c:\network test results %date:/=.%.txt" time /t >> "c:\network test results %date:/=.%.txt" ping %gateway% -n 20 >> "c:\network test results %date:/=.%.txt" goto :network2 :exit exit

but don't want have specify ip address, can take away need user input.

on command line can seek one:

for /f "tokens=2 delims=:" %g in ('netsh interface ip show address ^| findstr "default gateway"') ping %g

note, within batch-file must double %, i.e.

for /f "tokens=2 delims=:" %%g in ('netsh interface ip show address ^| findstr "default gateway"') ping %%g

windows batch-file ping

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -