标题: [网络连接] [分享]批处理切换国内外主流DNS [打印本页]
作者: impk 时间: 2019-7-23 12:30 标题: [分享]批处理切换国内外主流DNS
本帖最后由 impk 于 2019-7-23 12:32 编辑
- @echo off
- color 2F
-
- @echo.
- @echo.
- @echo. 1. 国外混合DNS
- @echo.
- @echo. 2. 国内混合DNS
- @echo.
- @echo. 3. 云耀DNS
- @echo.
- @echo. 4. 谷歌DNS
- @echo.
- @echo. 5. 114DNS
- @echo.
- @echo. 6. 阿里DNS
- @echo.
- @echo.
- echo. 输入序号选择DNS:
-
- set /p id=
- if "%id%"=="1" goto 国外混合DNS
- if "%id%"=="2" goto 国内混合DNS
- if "%id%"=="3" goto 云耀DNS
- if "%id%"=="4" goto 谷歌DNS
- if "%id%"=="5" goto 114DNS
- if "%id%"=="6" goto 阿里DNS
-
- :国外混合DNS
- netsh interface ip set dns name="本地连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="本地连接" addr=8.8.8.8
- netsh interface ip set dns name="无线网络连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="无线网络连接" addr=8.8.8.8
- exit
-
- :国内混合DNS
- netsh interface ip set dns name="本地连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="本地连接" addr=223.5.5.5
- netsh interface ip set dns name="无线网络连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="无线网络连接" addr=223.5.5.5
- exit
-
- :云耀DNS
- netsh interface ip set dns name="本地连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="本地连接" addr=1.0.0.1
- netsh interface ip set dns name="无线网络连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="无线网络连接" addr=1.0.0.1
- exit
-
- :谷歌DNS
- netsh interface ip set dns name="本地连接" source=static addr=8.8.8.8
- netsh interface ip add dns name="本地连接" addr=8.8.4.4
- netsh interface ip set dns name="无线网络连接" source=static addr=8.8.8.8
- netsh interface ip add dns name="无线网络连接" addr=8.8.4.4
- exit
-
- :114DNS
- netsh interface ip set dns name="本地连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="本地连接" addr=114.114.115.115
- netsh interface ip set dns name="无线网络连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="无线网络连接" addr=114.114.115.115
- exit
-
- :阿里DNS
- netsh interface ip set dns name="本地连接" source=static addr=223.5.5.5
- netsh interface ip add dns name="本地连接" addr=223.6.6.6
- netsh interface ip set dns name="无线网络连接" source=static addr=223.5.5.5
- netsh interface ip add dns name="无线网络连接" addr=223.6.6.6
- exit
复制代码
作者: Batcher 时间: 2019-7-23 12:57
4-18行建议删除@
27行下面建议加个条件,防止用户输入1-6之外的字符导致意外执行:国外混合DNS
作者: impk 时间: 2019-7-23 13:06
回复 2# Batcher
if "%id%"=="7" exit
我想把此处的7替换成1-6以外的全部字符 应该怎么写?
作者: Batcher 时间: 2019-7-23 13:24
回复 3# impk - if "%id%"=="1" (
- goto :国外混合DNS
- ) else if "%id%"=="2" (
- goto :国内混合DNS
- ) else if "%id%"=="3" (
- goto :云耀DNS
- ) else if "%id%"=="4" (
- goto :谷歌DNS
- ) else if "%id%"=="5" (
- goto :114DNS
- ) else if "%id%"=="6" (
- goto :阿里DNS
- ) else (
- goto :eof
- )
复制代码
建议使用 goto :eof 因为 exit 不方面调试代码
作者: impk 时间: 2019-7-23 13:41
本帖最后由 impk 于 2019-8-31 14:55 编辑
- @echo off
- color 2F
-
- :start
- echo.
- echo.
- echo. 切换DNS服务器
- echo.
- echo.
- echo. 1. 国外混合DNS 2. 云耀DNS 3. 谷歌DNS
- echo.
- echo. 4. 国内混合DNS 5. 信风DNS 6. 阿里DNS
- echo.
- echo. 7. 退出
- echo.
- echo.
-
- set /p id= 输入序号选择DNS:
- if "%id%"=="1" goto :国外混合DNS
- if "%id%"=="2" goto :云耀DNS
- if "%id%"=="3" goto :谷歌DNS
- if "%id%"=="4" goto :国内混合DNS
- if "%id%"=="5" goto :信风DNS
- if "%id%"=="6" goto :阿里DNS
- if "%id%"=="7" exit
- exit
-
- :国外混合DNS
- netsh interface ip set dns name="本地连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="本地连接" addr=8.8.8.8
- netsh interface ip set dns name="无线网络连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="无线网络连接" addr=8.8.8.8
- cls && goto :start
-
- :国内混合DNS
- netsh interface ip set dns name="本地连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="本地连接" addr=223.5.5.5
- netsh interface ip set dns name="无线网络连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="无线网络连接" addr=223.5.5.5
- cls && goto :start
-
- :云耀DNS
- netsh interface ip set dns name="本地连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="本地连接" addr=1.0.0.1
- netsh interface ip set dns name="无线网络连接" source=static addr=1.1.1.1
- netsh interface ip add dns name="无线网络连接" addr=1.0.0.1
- cls && goto :start
-
- :谷歌DNS
- netsh interface ip set dns name="本地连接" source=static addr=8.8.8.8
- netsh interface ip add dns name="本地连接" addr=8.8.4.4
- netsh interface ip set dns name="无线网络连接" source=static addr=8.8.8.8
- netsh interface ip add dns name="无线网络连接" addr=8.8.4.4
- cls && goto :start
-
- :信风DNS
- netsh interface ip set dns name="本地连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="本地连接" addr=114.114.115.115
- netsh interface ip set dns name="无线网络连接" source=static addr=114.114.114.114
- netsh interface ip add dns name="无线网络连接" addr=114.114.115.115
- cls && goto :start
-
- :阿里DNS
- netsh interface ip set dns name="本地连接" source=static addr=223.5.5.5
- netsh interface ip add dns name="本地连接" addr=223.6.6.6
- netsh interface ip set dns name="无线网络连接" source=static addr=223.5.5.5
- netsh interface ip add dns name="无线网络连接" addr=223.6.6.6
- cls && goto :start
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |