以下代码方便切换ip地址,mark一下,很早前学习别人的编法写的,参考作者忘记了,so 谢了先
今天想来怕以后不见到 顾备份先
@echo off
title 自动配置ip
echo
:start
cls
ECHO ================================
ECHO 请选择要换的ip
ECHO ————————————————
echo 本地连接---------1
echo.
echo 本地连接---设置宿舍ip地址……………2
echo.
echo 本地连接---设置实验室IP地址………………3
echo.
echo 无线连接---设置实验室IP地址………………4
echo.
echo 无线连接---自动获取--------------------5
echo.
@set /p UserSelection=选择(1,2,3,4,5)
if %UserSelection% LEQ 5 if %UserSelection% GEQ 1 goto selection
goto start
:selection
@if "%UserSelection%"=="1" goto 1
@if "%UserSelection%"=="2" goto 2
@if "%UserSelection%"=="3" goto 3
@if "%UserSelection%"=="4" goto 4
@if "%UserSelection%"=="5" goto 5
:1
echo 本地连接---设置ip自动获取 请稍候...
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip set dns name="本地连接" source=dhcp
pause
exit
:2
echo 本地连接---设置宿舍ip地址 请稍候...
netsh interface ip set address name="本地连接" static 219.220.98.221 255.255.255.0 219.220.98.1
netsh interface ip set dns name="本地连接" static 210.34.32.66 primary
netsh interface ip add dns name="本地连接" 218.85.157.99
echo 宿舍IP已设置。
pause
exit
:3
echo 本地连接---设置实验室IP地址 请稍候...
netsh interface ip set address name="本地连接" static 10.192.5.62 255.255.255.0 10.192.5.254
netsh interface ip set dns name="本地连接" static 218.85.157.99 primary
netsh interface ip add dns name="本地连接" 210.34.32.66
echo 实验室ip地址设置完毕
pause
exit
:4
echo 无线连接---设置实验室无线IP地址 请稍候...
netsh interface ip set address name="无线网络连接" static 10.192.5.210 255.255.255.0 10.192.5.254
netsh interface ip set dns name="无线网络连接" static 218.85.157.99 primary
netsh interface ip add dns name="无线网络连接" 210.34.32.66
echo 实验室ip地址设置完毕
pause
exit
:5
echo 无线连接---设置自动获取IP及DNS服务器 请稍后...
netsh interface IP set Address "无线网络连接" DHCP
netsh interface IP set Dns "无线网络连接" DHCP
echo 无线连接IP地址设置完毕
pause
exit
转载于:https://blog.51cto.com/loma1990/1329267