返回

怎么快速修改本地IP地址的命令行bat文件?一个快速修改本地IP地址的命令行bat文件

时间:2016年12月15日 04:40评论:0

@echo off
mode con cols=55 lines=15
rem 设置公用变量
set net_interface="本地连接"

:CHOICE
color a
cls
echo *****************IP快速切换程序***********************
echo ----【IP设置功能】---------------【系统功能】-----
echo -----1.修改为HomeIP-------------------------------
echo -----2.修改为OfficeIP-------------r.重启网卡------
echo -----3.修改为自动获取-------------X.退出程序------
echo.
echo 本程序仅对名称为"%net_interface%"的网卡进行设置-----
echo ******************************Tools By Li.Zero********
echo.
echo.

:mu
set /p choice= 请输入您的选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto home_ip
if /i "%choice%"=="2" goto office_ip
if /i "%choice%"=="3" goto DHCP
if /i "%choice%"=="r" goto reboot
if /i "%choice%"=="X" goto END
echo.
echo.
echo 输入的选择不正确,请重新输入!
echo.
echo.
GOTO CHOICE
pause

:home_ip
cls
echo.
echo 正在设置IP为home_ip,请等待...
echo.
echo 设置IP中...
netsh interface ip set address "%net_interface%" source=static addr=192.168.1.141 mask=255.255.255.0
echo 设置IP成功...设置网关中...
netsh interface ip set address name="%net_interface%" gateway=192.168.1.1 gwmetric=1
echo 设置网关成功...设置DNS中...
netsh interface ip set dns "%net_interface%" static 202.100.192.68
netsh interface ip add dns "%net_interface%" 202.100.199.8 index=2
echo 设置完成。
pause | echo 按任意键返回选择菜单。
GOTO CHOICE

:office_ip
cls
echo.
echo 正在设置IP为office_ip,请等待...
echo.
echo 设置IP中...
netsh interface ip set address "%net_interface%" source=static addr=192.168.253.141 mask=255.255.255.0
echo 设置IP成功...设置网关中...
netsh interface ip set address name="%net_interface%" gateway=192.168.253.1 gwmetric=1
echo 设置网关成功...设置DNS中...
netsh interface ip set dns "%net_interface%" static 202.100.192.68
netsh interface ip add dns "%net_interface%" 202.100.199.8 index=2
pause |echo 任务完成,按任意键返回选择菜单。
GOTO CHOICE

:DHCP
echo.
echo 正在设置IP为自动获取,请等待...
echo.
echo 设置IP中...
netsh interface ip set address name="%net_interface%" source=dhcp
echo 设置网关成功...设置DNS中...
netsh interface ip set dns "%net_interface%" source=dhcp
pause |echo 任务完成,按任意键返回选择菜单。
GOTO CHOICE

:reboot
echo 重启网卡中...请稍等...
netsh interface set interface "%net_interface%" disabled
netsh interface set interface "%net_interface%" enable
pause |echo 任务完成,按任意键返回选择菜单。
GOTO CHOICE

:end
exit

相关文章
猜你喜欢
用户评论