• 快速切换IP的批处理!


    内容如下:

    @echo off
    color 1A
    Title [SMART专用 IP设置V1.0]
    
    cls
    echo.
    echo SMART专用 IP设置V1.0     %date%%time%
    echo.
    
    @ipconfig /all > c:ipconRt.txt
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”Description” c:ipconRt.txt’) do (
    echo 网卡描述:%%k
    
    goto netaddress
    )
    :netaddress
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”IP Address” c:ipconRt.txt’) do (
    echo   IP地址:%%k
    
    goto gateway
    )
    :gateway
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”Gateway” c:ipconRt.txt’) do (
    echo 网关地址:%%k
    
    goto mask
    )
    :mask
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”Mask” c:ipconRt.txt’) do (
    echo 子网掩码:%%k
    
    goto dns
    )
    :dns
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”DNS Servers” c:ipconRt.txt’) do (
    echo DNS地址:%%k
    
    goto mac
    )
    :mac
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”Physical Address” c:ipconRt.txt’) do (
    echo 物理地址:%%k
    
    goto dispE
    )
    :dispE
    echo.
    
    del c:ipconRt.txt
    echo ******************************
    echo * 本脚本由Major提供,欢迎使用 *
    echo * ————————– * 
    echo *                            * 
    echo *       1)无限制16.179_IP    * 
    echo *       2)高速10.140_IP      *
    echo *       3)自动获取           *
    echo *       4)手动设置           *
    echo *   Enter)退出               *
    echo ******************************
    echo.
    
    :START
    
    set   VAR=
    
    set/p VAR=请选择网络[1,2,3,4,Enter]进行切换:
    
    if “%VAR%”==”1” goto school
    
    if “%VAR%”==”2” goto home
    
    if “%VAR%”==”3” goto auto
    
    if “%VAR%”==”4” goto manul
    
    if “%VAR%”==”” goto exit
    
    goto end
    
    :exit
    echo.
    
    rem @ipconfig
    echo 保留当前配置。
    
    goto end
    
    :school
    echo.
    echo 正在处理中,请稍候…
    echo.
    
    @netsh interface ip set address “本地连接” static 192.168.16.179 255.255.255.0 192.168.16.1 >NUL
    
    @netsh interface ip set dns “本地连接” static 202.96.128.86 >NUL
    
    @netsh interface ip add dns “本地连接” 202.96.128.166
    
    goto end
    
    :home
    echo.
    echo 正在处理中,请稍候…
    echo.
    
    @netsh interface ip set address “本地连接” static 192.168.10.140 255.255.255.0 192.168.10.1 >NUL
    
    @netsh interface ip set dns “本地连接” static 202.96.128.86 >NUL
    
    @netsh interface ip add dns “本地连接” 202.96.128.166
    
    goto end
    
    :auto
    echo.
    echo 正在处理中,请稍候…
    echo.
    
    @netsh interface ip set address “本地连接” dhcp >NUL
    
    @netsh interface ip set dns “本地连接” dhcp >NUL
    
    @echo 网络地址: 自动获取
    
    goto end
    
    :manul
    echo.
    
    set   VAR1=
    
    set/p VAR1=请输入IP地址:
    echo.
    
    if “%VAR1%”==”” goto setGATEWAY
    echo 正在处理中,请稍候…
    echo.
    
    @netsh interface ip set address “本地连接” static addr=%VAR1% mask=255.255.255.0 >NUL
    
    @echo   IP地址: %VAR1%
    
    @echo.
    
    :setGATEWAY
    
    set   VAR2=
    
    set/p VAR2=请输入网关地址:
    echo.
    
    if “%VAR2%”==”” goto setDNS
    echo 正在处理中,请稍候…
    echo.
    
    @netsh interface ip set address “本地连接” static gateway=%VAR2% gwmetric=1 >NUL
    
    @echo   网关地址: %VAR2%
    
    @echo.
    
    :setDNS
    
    set   VAR3=
    
    set/p VAR3=请输入DNS地址:
    echo.
    
    if “%VAR3%”==”” goto START
    echo 正在处理中,请稍候…
    echo.
    
    @netsh interface ip set dns “本地连接” static addr=%VAR3% register=PRIMARY >NUL
    
    @echo   DNS地址: %VAR3%
    
    @echo.
    
    :end
    
    @echo.
    
    @ipconfig /all > c:ipconRt.txt
    
    :netaddress
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”IP Address” c:ipconRt.txt’) do (
    echo   IP地址:%%k
    
    goto gateway
    )
    :gateway
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”Gateway” c:ipconRt.txt’) do (
    echo 网关地址:%%k
    
    goto mask
    )
    :mask
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”Mask” c:ipconRt.txt’) do (
    echo 子网掩码:%%k
    
    goto dns
    )
    :dns
    
    for /f “tokens=1,2* delims=:” %%i in (‘findstr /NIC:”DNS Servers” c:ipconRt.txt’) do (
    echo DNS地址:%%k
    
    goto dispE
    )
    :dispE
    echo.
    
    del c:ipconRt.txt
    echo 处理完成,谢谢使用!
    echo.
    
    pause


    请将文本保存为 .bat 或 .cmd的格式

    【注】本文仅作为原理参考!!! 大家可以根据自己的情况来修改IP,请将里面的IP改为你自己需要的!

    博客地址:http://www.cnblogs.com/colinliu/
    博客版权:本文以学习、记录、分享为目的。欢迎大家转载,但务必注明原文地址,谢谢合作!
  • 相关阅读:
    Enforcing the correct protocol for partially SSL secured SharePoint sites
    SQL SERVER – Attach mdf file without ldf file in Database
    How to Get SharePoint Client Context in SharePoint Apps (Provider Hosted / SharePoint Access ) in CSOM (Client Side Object Model)
    git--rebase
    flutter widget
    Flutter--FutureBuilder/StreamBuilder(待补)
    Flutter-notification和notificatioLisener
    flutter context踩坑
    Flutter-gestureDetector的滑动事件小试
    flutter -忽略点击事件
  • 原文地址:https://www.cnblogs.com/colinliu/p/5216042.html
Copyright © 2020-2023  润新知