win7电脑现有6个dns地址,这6个地址需要全部删除,同时添加2个新地址,请问批处理指令怎样写
1条回答 默认 最新
- 游一游走一走 2022-09-30 17:51关注
@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
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用