win7电脑现有6个dns地址,这6个地址需要全部删除,同时添加2个新地址,请问批处理指令怎样写
win7电脑现有6个dns地址,这6个地址需要全部删除,同时添加2个新地址,请问批处理指令怎样写
收起
@ECHO ON
netsh interface ipv4 show dns
SETLOCAL EnableDelayedExpansion
SET adapterName=
FOR /F "tokens=* delims=:" %%a IN ('IPCONFIG ^| FIND /I "以太网适配器"') DO (
SET adapterName=%%a
REM Removes "Ethernet adapter" from the front of the adapter name
SET adapterName=!adapterName:~7!
REM Removes the colon from the end of the adapter name
SET adapterName=!adapterName:~0,-1!
echo %%adapterName
netsh interface ipv4 delete dns name="!adapterName!" all
netsh interface ipv4 set dns name="!adapterName!" static 223.5.5.5 primary
netsh interface ipv4 add dns name="!adapterName!" 8.8.8.8 index=2
)
ipconfig /flushdns
netsh interface ipv4 show dns
:EOF
我将192.168.0.2和3改了,运行了没反应
修改了,请再试下,记得用administrator执行
保存bat文件时用ansi编码
报告相同问题?