移动宽带路线存在dns更新不及时现象,需要手动指定DNS
@echo off & title 修改DNS By 虎式 & color 3e
set "Conname=1"
for /f "tokens=4*" %%a in ('netsh interface show interface ^| findstr "已连接"') do set "ConName=%%~a"
if "%ConName%"=="1" (
echo. 网络未连接
goto exit
)
echo 正在使用的网络连接为 %ConName%
echo.
echo 修改主dns为 223.5.5.5
netsh interface ip set dns name="%ConName%" source=static addr=223.5.5.5
echo 完成
echo.
echo 修改副DNS为 223.6.6.6
netsh interface ip add dns "%ConName%" 223.6.6.6 index=2
echo 完成
echo.
echo.
echo.任意键退出 & pause>nul
:exit
echo.
echo. 正在退出
ping -n 3 127.1>nul
exit
以上可以直接运行,自动识别当前已连接网络,并修改其dns
左拼右凑总算把代码拼出来了