@echo off
echo 输入1更改DNS到114.114.114.114,输入2更改DNS到DHCP(自动获取)。注:网络适配器的名字中不能有空格
set /p change=
if %change% EQU 1 (^
echo 更改DNS到114.114.114.114 &^
for /f "tokens=4,5 delims= " %%i in ('netsh interface show interface ^|findstr /r "已启用"') ^
do echo netsh interface ip set dns "%%i" static 114.114.114.114 & netsh interface ip set dns "%%i" static 114.114.114.114 & echo 更改完成 )^
else echo 更改DNS到DHCP(自动获取)&^
for /f "tokens=4,5 delims= " %%i in ('netsh interface show interface ^|findstr /r "已启用"') ^
do echo netsh interface ip set dns "%%i" dhcp & netsh interface ip set dns "%%i" dhcp & echo 更改完成
ipconfig /flushdns
pause