求达人帮我修改下这个批处理

来源:百度知道 编辑:UC知道 时间:2024/09/21 14:42:51
@echo off
echo.
echo Check Current IP Address:
ipconfig
echo.
netsh interface ip set dns "本地连接" static 222.222.222.222 primary
netsh interface ip add dns "本地连接" 222.222.222.222 2
netsh interface ip set dns "本地连接 2" static 222.222.222.222 primary
netsh interface ip add dns "本地连接 2" 222.222.222.222 2
netsh interface ip set dns "本地连接 3" static 222.222.222.222 primary
netsh interface ip add dns "本地连接 3" 222.222.222.222 2
netsh interface ip set dns "本地连接 4" static 222.222.222.222 primary
netsh interface ip add dns "本地连接 4" 222.222.222.222 2
close

这是个DNS修改的bat 求达人帮忙简化一下
条件:当“本地连接”修改命令成功时不执行下面的命令 以此类推

或者有没有其他更好更简化的BAT呢?
我的目的就是想编辑个BAT 来更改机器的DNS 由于有很多台机器 不可能一台一台手动改 所以要远程调用BAT 但是有的机器中的网卡名称为“本地连接” 而有的机器中的网卡名称为“本地连接 2” 有的机器中的网卡名称为“本地连接 3” 有的机器中的网卡名称为“本地连接 4”

@echo off
echo.
echo Check Current IP Address:
ipconfig
echo.
netsh interface ip set dns "本地连接" static 222.222.222.222 primary
if %errorlevel%==0 goto :eof
netsh interface ip add dns "本地连接" 222.222.222.222 2
if %errorlevel%==0 goto :eof
netsh interface ip set dns "本地连接 2" static 222.222.222.222 primary
if %errorlevel%==0 goto :eof
netsh interface ip add dns "本地连接 2" 222.222.222.222 2
if %errorlevel%==0 goto :eof
netsh interface ip set dns "本地连接 3" static 222.222.222.222 primary
if %errorlevel%==0 goto :eof
netsh interface ip add dns "本地连接 3" 222.222.222.222 2
if %errorlevel%==0 goto :eof
netsh interface ip set dns "本地连接 4" static 222.222.222.222 primary
if %errorlevel%==0 goto :eof
netsh interface ip add dns "本地连接 4" 222.222.222.222 2
close