作为IT从业人士,我们经常需要在公司上网(严格意义上来说本人不算IT人士,顶多算个计算机科学的爱好者,也许连个爱好者
也算不上),但是公司和家里的IP地址通常不一样(也许有人会说,公司和家里的IP一定不一样,当设置为192段的公有IP的时候,有
可能一样),每次开机后都需要修改IP地址,老麻烦了,怎么办?
程序猿们(哈哈,不知道为什么用搜狗打字首选的就是这个,迷惑中...............)当然不愿意每次都手动修改,写个程序代码自动
修改就行, 但是那样太麻烦,我们知道在Win下批处理是个简单易用的工具,因此可以用bat文件来实现这个功能。下面贴一段我自己
使用的代码给大家看看:
@echo off ::color 3f ::mode con cols=40 lines=15 title Auto IP Config :start cls echo. echo ****************************************** echo Wellcome to Auto IP Config Tool echo. echo 1.Change to Office IP echo. echo 2.Change to local IP echo. echo 0.Exit echo. echo ******************************************* echo. set /p choice=Enter your choice: if "%choice%"=="1" goto office if "%choice%"=="2" goto Home if "%choice%"=="0" exit echo Incorrect choice,Please input again....... pause>nul goto start :office cls echo. echo Setting Office IP,Please waitting...... echo. set net_interface="本地连接" echo Setting IP..... netsh interface ip set address "%net_interface%" source=static addr=192.168.64.184 mask=255.0.0.0 echo IP config success echo. echo Config GetWay...... netsh interface ip set address name="%net_interface%" gateway=192.168.64.240 gwmetric=1 echo Getway confing success echo. echo Setting DNS...... netsh interface ip set dns "%net_interface%" static 219.147.1.66 echo Preferred DNS confing success echo. netsh interface ip add dns "%net_interface%" 219.146.1.66 index=2 echo Backup DNS config success echo. echo DNS confing success... echo. echo IP confing successfully,press any key to quit...... pause>nul exit goto start :home cls echo. echo Setting Local IP,Please waitting...... echo. set net_interface="本地连接" echo Setting IP..... netsh interface ip set address "%net_interface%" source=static addr=192.168.1.111 mask=255.255.255.0 echo IP config success...... Config GetWay...... netsh interface ip set address name="%net_interface%" gateway=192.168.1.1 gwmetric=1 echo Getway confing success...Setting DNS...... netsh interface ip set dns "%net_interface%" static 218.85.152.99 netsh interface ip add dns "%net_interface%" 218.85.157.99 index=2 echo IP confing successfully,press any key to quit...... pause>nul exit goto start
欢饮转载和使用,嘻嘻,也许能为你的日常工作增加半分的方便.........