|
自动获取网关地址和dns,如果dns和网关相同(路由代理dns),就ping公共dns114。
- @echo off
- set "com=wmic Path Win32_NetworkAdapterConfiguration where "IPEnabled='True'" get DefaultIPGateway /value"
- for /f tokens^=2delims^=^" %%a in ('%com%') do set "gwip=%%a"
- for /f "delims=: tokens=2" %%a in ('ipconfig /all^|find "DNS 服务器"') do (
- for /f %%i in ('echo %%a') do set DNS=%%i
- )
- IF /I "%DNS%" EQU "%gwip%" (start cmd /k ping -n 10 114.114.114.114) ELSE (start cmd /k ping -n 10 %DNS%)
- ping -n 10 %gwip%
- ping 127.0.0.1 -n 15>nul
- taskkill /im cmd.exe /t
- exit
复制代码 |
|