win7 批处理自动 修改本地IP地址、无线IP地址.bat

@echo off
 title Alpha - IP地址修改工具 
MODE con: COLS=80 lines=20

rem IP地址列表

set lname=本地连接
rem 本地连接IP地址一 公司IP地址
set lAdd1=192.168.3.126
 set lmask1=255.255.252.0
 set lGat1=192.168.3.254
 set ldns11=202.96.199.133
 set ldns12=202.106.196.115
 rem 本地连接IP地址二 家庭IP地址
set lAdd2=192.168.0.115
 set lmask2=255.255.255.0
 set lGat2=192.168.0.1
 set ldns21=202.96.199.133
 set ldns22=202.106.196.115

set wname=无线网络连接
rem 无线连接IP地址一 公司IP地址
set wAdd1=%lAdd1%
 set wmask1=%lmask1%
 set wGat1=%lGat1%
 set wdns11=%ldns11%
 set wdns12=%ldns12%
 rem 无线连接IP地址二 家庭IP地址
set wAdd2=%lAdd2%
 set wmask2=%lmask2%
 set wGat2=%lGat2%
 set wdns21=%ldns21%
 set wdns22=%ldns21%


 :home
 cls
 @echo.
 @echo      Alpha - IP地址修改工具    ( KYT -- PanFu )
@echo.
 @echo           1:设置 %lname%
 @echo           2:设置 %wname%
 @echo.
 @echo 警告:WIN7系统必须 单击右键 [以管理员身份运行(A)] !
@echo.
 @echo.
 set shut="" 
 set /p shut="请输入 【<1> 或 <2> 或 <q>退出】 并按回车键 :" 
IF NOT "%shut%"=="" ( 
 if %shut% NEQ "" SET shut=%shut:~0,1% 
 ) else ( 
 set shut="") 
 if /i %shut%==1 goto locally
 if /i %shut%==2 goto wireless
 if /i %shut%==q exit
 goto home

:locally
 cls
 @echo.
 @echo      修改 %lname% IP地址      ( KYT -- PanFu )
@echo.
 @echo           1:设置 %lname% 自动获取IP地址
@echo           2:设置 %lname% IP地址为公司IP %lAdd1%
 @echo           3:设置 %lname% IP地址为专用IP %lAdd2%
 @echo.
 @echo.
 set shut="" 
 set /p shut="请输入 【<1> 或 <2> 或 <3> 或 <q>退出】 并按回车键 或者 按<回车键>返回主菜单 :" 
IF NOT "%shut%"=="" ( 
 if %shut% NEQ "" SET shut=%shut:~0,1% 
 ) else ( 
 set shut="") 
 if /i %shut%==1 goto locallyone
 if /i %shut%==2 goto locallytwo
 if /i %shut%==3 goto locallythree
 if /i %shut%==q exit
 goto home

:wireless
 cls
 @echo.
 @echo      修改 %wname% IP地址      ( KYT -- PanFu )
@echo.
 @echo           1:设置 %wname% 自动获取IP地址
@echo           2:设置 %wname% IP地址为公司IP %wAdd1%
 @echo           3:设置 %wname% IP地址为专用IP %wAdd2%
 @echo.
 @echo.
 set shut="" 
 set /p shut="请输入 【<1> 或 <2> 或 <3> 或 <q>退出】 并按回车键 或者 按<回车键>返回主菜单 :" 
IF NOT "%shut%"=="" ( 
 if %shut% NEQ "" SET shut=%shut:~0,1% 
 ) else ( 
 set shut="") 
 if /i %shut%==1 goto wirelessone
 if /i %shut%==2 goto wirelesstwo
 if /i %shut%==3 goto wirelessthree
 if /i %shut%==q exit
 goto home

rem  设置 本地网络连接 开始
:locallyone
 @echo.
 @echo 正在设置 %lname% IP地址 请稍后。。。
call :autolocall %lname% >nul
 @echo 设置 %lname% 自动获取IP地址成功!!
@echo.
 @echo.
 goto three

:locallytwo
 @echo.
 @echo 正在设置 %lname% IP地址 请稍后。。。
call :autowireless %wname% >nul
 cmd /c netsh interface ip set address name="%lname%" static %ladd1% %lmask1% %lGat1% >nul
 cmd /c netsh interface ip add dns name="%lname%" %ldns11% index=1 >nul
 cmd /c netsh interface ip add dns name="%lname%" %ldns12% index=2 >nul
 @echo 设置 %lname% IP地址成功!!!
@echo.
 @echo 当前IP地址:   %ladd1%
 @echo 当前子网掩码: %lmask1%
 @echo 当前默认网关: %lGat1%
 @echo 当前DNS1地址:%ldns11%
 @echo 当前DNS2地址:%ldns12%
 @echo.
 @echo.
 goto three

:locallythree
 @echo.
 @echo 正在设置 %lname% IP地址 请稍后。。。
call :autowireless %wname% >nul
 cmd /c netsh interface ip set address name="%lname%" static %ladd2% %lmask2% %lGat2% >nul
 cmd /c netsh interface ip add dns name="%lname%" addr=%ldns21% index=1 >nul
 cmd /c netsh interface ip add dns name="%lname%" addr=%ldns22% index=2 >nul
 @echo 设置 %lname% IP地址成功!!!
@echo.
 @echo 当前IP地址:   %ladd2%
 @echo 当前子网掩码: %lmask2%
 @echo 当前默认网关: %lGat2%
 @echo 当前DNS1地址:%ldns21%
 @echo 当前DNS2地址:%ldns22%
 @echo.
 @echo.
 goto three
 :: 设置 本地网络连接 结束

::  设置 无线网络连接 开始
:wirelessone
 @echo.
 @echo 正在设置 %wname% IP地址 请稍后。。。
call :autowireless %wname% >nul
 @echo 设置 %wname% 自动获取IP地址成功!!
@echo.
 @echo.
 goto three

:wirelesstwo
 @echo.
 @echo 正在设置 %wname% IP地址 请稍后。。。
call :autolocall %lname% >nul
 cmd /c netsh interface ip set address name="%wname%" static %wadd1% %wmask1% %wGat1% >nul
 cmd /c netsh interface ip add dns name="%wname%" %wdns11% index=1 >nul
 cmd /c netsh interface ip add dns name="%wname%" %wdns12% index=2 >nul
 @echo 设置 %wname% IP地址成功!!!
@echo.
 @echo 当前IP地址:   %wadd1%
 @echo 当前子网掩码: %wmask1%
 @echo 当前默认网关: %wGat1%
 @echo 当前DNS1地址:%wdns11%
 @echo 当前DNS2地址:%wdns12%
 @echo.
 @echo.
 goto three

:wirelessthree
 @echo.
 @echo 正在设置 %wname% IP地址 请稍后。。。
call :autolocall %lname% >nul
 cmd /c netsh interface ip set address name="%wname%" static %wadd2% %wmask2% %wGat2% >nul
 cmd /c netsh interface ip add dns name="%wname%" %wdns121% index=1 >nul
 cmd /c netsh interface ip add dns name="%wname%" %wdns122% index=2 >nul
 @echo 设置 %wname% IP地址成功!!!
@echo.
 @echo 当前IP地址:   %wadd2%
 @echo 当前子网掩码: %wmask2%
 @echo 当前默认网关: %wGat2%
 @echo 当前DNS1地址:%wdns21%
 @echo 当前DNS2地址:%wdns22%
 @echo.
 @echo.
 goto three
 :: 设置 无线网络连接 结束

:three
 ::pause >nul
 set shut="" 
 set /p shut="请输入 【<a>返回主菜单】 或者 按<其他键>退出:" 
IF NOT "%shut%"=="" ( 
 if %shut% NEQ "" SET shut=%shut:~0,1% 
 ) else ( 
 set shut="") 
 if /i %shut%==a goto home
 exit

:autolocall
 cmd /c netsh interface ip set address name="%lname%" static 0.0.0.0  0.0.0.0  0.0.0.0 >nul
 cmd /c netsh interface ip set address name="%lname%" source=dhcp >nul
 cmd /c netsh interface ip set dns name="%lname%" source=dhcp >nul
 ::@echo 设置 %lname% 自动获取IP地址成功!
goto :eof

:autowireless
 cmd /c netsh interface ip set address name="%wname%" static 0.0.0.0  0.0.0.0  0.0.0.0 >nul
 cmd /c netsh interface ip set address name="%wname%" source=dhcp >nul
 cmd /c netsh interface ip set dns name="%wname%" source=dhcp >nul
 ::@echo 设置 %wname% 自动获取IP地址成功!
goto :eof

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值