打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
vista批处理实现的ip地址切换(你一定用的着)

@echo off
cls
echo.

rem  新区ip配置
rem ip        //设置IP地址
set ip1=10.13.40.60
rem gw         //设置网关
set gw1=10.13.40.1
rem netmasks   //设置子网掩码
set netmasks1=255.255.254.0


rem  老区ip配置
rem ip         //设置IP地址
set ip2=192.168.1.123
rem gw         //设置网关
set gw2=192.168.1.1
rem netmasks   //设置子网掩码
set netmasks2=255.255.255.0

rem  宿舍ip配置
rem ip         //设置IP地址
set ip3=192.168.1.123
rem gw         //设置网关
set gw3=192.168.1.1
rem netmasks   //设置子网掩码
set netmasks3=255.255.255.0

rem dns1       //设置主DNS
set dns1=61.147.37.1
rem dns2       //设置辅DNS
set dns2=61.177.7.1

 


set eth=本地连接

 

:MENU
echo.
echo 新区设置请按-1
echo.
echo 老区设置请按-2
echo.
echo 宿舍默认请按-3
echo.
echo 自动获取请按-4
echo.
echo 察看状态请按-5
echo.
echo.
set /p KEY= 请输入您的选择:

if %KEY% == 1 goto 新区
if %KEY% == 2 goto 老区
if %KEY% == 3 goto 宿舍
if %KEY% == 4 goto DHCP
if %KEY% == 5 goto LOOK
goto END

:LOOK
echo.
ipconfig
echo.
echo 本程序默认修改的是“本地连接”的设置
echo.
echo 需要修改请按相应的数字键,
echo.
echo 例如:输入2表示改为“本地连接 2”
echo.
set /p INTEMP= [请输入本地连接的编号]
if %INTEMP% == 1 set eth=本地连接
if %INTEMP% == 2 set eth=本地连接 2
if %INTEMP% == 3 set eth=本地连接 3
if %INTEMP% == 4 set eth=本地连接 4
if %INTEMP% == 5 set eth=本地连接 5
cls
goto MENU

:新区

echo 正在将本机IP更改到:%ip1%

netsh interface ipv4 set address "%eth%" static %ip1% %netmasks1% %gw1%
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1%  primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo   IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end

 

:老区
@echo off

echo 正在将本机IP更改到:%ip2%

netsh interface ipv4 set address "%eth%" static %ip2% %netmasks2% %gw2%
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1%  primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo   IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end


:宿舍
@echo off

echo 正在将本机IP更改到:%ip3%

netsh interface ipv4 set address "%eth%" static %ip3% %netmasks3% %gw3%
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1%  primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo   IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end

:DHCP

echo 正在将本机IP更改为自动获取:

netsh interface ipv4 set address "%eth%" dhcp
echo 正在添加本机主DNS:%dns1%
netsh interface ipv4 set dnsserver "%eth%" static %dns1%  primary
echo 正在添加本机副DNS:%dns2%
netsh interface ipv4 add dnsserver "%eth%" %dns2% index=2
echo ------------------------------
echo   IP更改完毕,检查当前配置...
echo ------------------------------
ipconfig /all
pause
goto end

:end
pause

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
DIY一个批处理IP更改
【Windows】win10电脑通过bat脚本自动配置IP地址
Windows7 IP任意切换
非常实用的原创小工具:EasyIP
命令行设置IP地址 - 隔壁老王
自动获取IP
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服