批处理自动修改办公IP(附源码以及学习文件)

我们经常出入与不同的场合,ip的地址的手动改写又比较麻烦,所以我为大家提供了一篇自动改IP的博客,欢迎大家指点和学习;

首先查看本机的网络连接类型,win7的一般为“本地连接”,win8以及以上版本的一般为“以太网”,本例子以win8的作参考(我自己就是win8),下面附源代码(仅供参考):

将该文件复制到记事本上,命名为ip.bat形式的文件;

(请以管理员的方式运行,且不要被杀毒软件禁止启动了,bat文件杀毒软件是会禁止运行的)

@echo off
echo.
echo 		==============请输入序号修改办公区===========
echo				*********1、14教室(2514)*********
echo				*********2、22教室(2522)*********
echo				*********3、20教室(2520)*********
echo				*********4、17教室(2517)*********
echo				*********5、16教室(2516)*********
echo				*********6、寝室*********
echo			=============================================	
echo.

set /p input=请输入你要的选择:
if "%input%"=="1" (
netsh interface ip set address 以太网 static 192.168.14.218 255.255.255.0 192.168.14.254 
netsh interface ip set dns 以太网 static 114.114.114.114 primary
netsh interface ip add dns 以太网 8.8.8.8
echo 成功更改IP地址
echo.
goto end
)
if "%input%"=="2" (
netsh interface ip set address 以太网 static 192.168.20.218 255.255.255.0 192.168.20.254
netsh interface ip set dns 以太网 static 114.114.114.114 primary
netsh interface ip add dns 以太网 8.8.8.8
echo IP地址修改成功,您可以网上冲浪了!
echo.
goto end
)
if "%input%"=="3" (
netsh interface ip set address 以太网 static 192.168.19.218 255.255.255.0 192.168.19.254 
netsh interface ip set dns 以太网 static 114.114.114.114 primary
netsh interface ip add dns 以太网 8.8.8.8
echo.
echo IP地址修改成功,您可以网上冲浪了!
goto end
)
if "%input%"=="4" (
netsh interface ip set address 以太网 static 192.168.16.218 255.255.255.0 192.168.16.254 
netsh interface ip set dns 以太网 static 114.114.114.114 primary
netsh interface ip add dns 以太网 8.8.8.8
echo.
echo IP地址修改成功,您可以网上冲浪了!
goto end
)
if "%input%"=="5" (
netsh interface ip set address 以太网 static 192.168.15.218 255.255.255.0 192.168.15.254 
netsh interface ip set dns 以太网 static 114.114.114.114 primary
netsh interface ip add dns 以太网 8.8.8.8
echo.
echo IP地址修改成功,您可以网上冲浪了!
goto end
)
if "%input%"=="6" (
netsh interface ip set address 以太网 dhcp 
netsh interface ip set dns source=static addr=192.168.1.1 
echo.
echo IP地址修改成功,您可以网上冲浪了!
goto end
)
echo 请选择正确的IP类型选项
pause >nul
goto again
:end
注:我另外的一篇博客有学习文件和p处理源代码,不要积分的,欢迎大家指点和学习;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值