相信很多人跟我一样使用笔记本工作,而同样会遇到频繁在家和公司之间更换IP的情况,有没有省事的办法一次操作完成呢.答案是肯定的。经过我半天折腾,狂翻资料终于搞定撒~,好东东不敢独享,特拿出来与大家共享之。新建一个文本文件,复制如下代码,记住,保存时一定要把后缀名改为".bat"否则不能执行,切记!
ASP/Visual Basic代码
- @echo off
- color a
- set /p in=要设置IP请输入1,要自动获取IP请输入2:
- if "%in%"=="1" goto in
- if "%in%"=="2" goto out
- :in
- set /p d=通过网线连接请输入1,通过无线连接请输入2:
- if "%d%"=="1" goto lan
- if "%d%"=="2" goto wlan
- :out
- set /p d=通过网线连接请输入1,通过无线连接请输入2:
- if "%d%"=="1" set scon=本地连接
- if "%d%"=="2" set scon=无线网络连接
- echo 正在设置IP,请稍候......
- netsh.exe interface ip set address "%scon%" dhcp
- echo 正在设置DNS.请稍候......
- netsh.exe interface ip set dns "%scon%" dhcp
- ipconfig /flushdns
- goto end
- :lan
- set scon=本地连接
- goto sip
- :wlan
- set scon=无线网络连接
- goto sip
- :sip
- echo IP尾数通常为192.168.0.x的x值
- set /p setip=请输入你的IP尾数:
- echo 正在设置IP,请稍候......
- netsh.exe interface ip set address "%scon%" static 192.168.0.%setip% 255.255.255.0 192.168.0.1 1
- echo 正在设置DNS.请稍候......
- netsh.exe interface ip set dns "%scon%" static 202.106.196.115 primary
- netsh.exe interface ip add dns "%scon%" 202.96.199.133 2
- ipconfig /flushdns
- goto end
- :end
- echo 恭喜你,设置成功!如无意外,你已经能正常上网了.
- echo. & pause