接上文
非常实用的原创小工具:EasyIP。自己用批处理,最大的两个优点是小巧、灵活。但如果发出来供大家用,就要考虑N种情况,就会体积变大而且复杂起来。即,EasyIP是一个模板,大家可以启发而改造。下面附上我在用的版本,仅1KB,可实现切换IP,设定IE代理,测试网络功能。
------代码开始------>
:: 原程序为EasyIP v1.3,作者Lile。xbeta修改后自用
@echo off
set
ProxyServerValue=10.68.200.233:8080
set
ProxyOverrideValue="10.*,<local>"
set
NetConf="local"
set
TestIP="10.68.68.254"
if
"%1%"=="bj" goto bj
if
"%1%"=="0" goto dhcp
if
"%1%"=="p" goto proxy
if
"%1%"=="n" goto noproxy
if
"%1%"=="t" goto test
echo
命令有误,按任意退出。
pause
>nul
exit
:bj
set
MyIP=10.68.68.85
set
MyGateWay=10.68.68.254
set
MyMask=255.255.255.0
set
DNS1=10.68.100.211
set
DNS2=10.68.100.212
goto
setip
:dhcp
netsh
interface ip set address "%NetConf%" dhcp
netsh
interface ip set dns "%NetConf%" dhcp
exit
:setip
netsh
interface ip set address name="%NetConf%" source=static addr=%MyIP%
mask=%MyMask%
netsh
interface ip set address name="%NetConf%" gateway=%MyGateWay%
gwmetric=0
netsh
interface ip set dns name="%NetConf%" source=static addr=%DNS1%
register=PRIMARY
netsh
interface ip add dns name="%NetConf%" addr=%DNS2%
netsh
interface ip set wins name="%NetConf%" source=static
addr=none
exit
:proxy
reg add
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyServer /t reg_sz /d %ProxyServerValue% /f
reg add
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyOverride /t reg_sz /d %ProxyOverrideValue%
/f
reg add
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t reg_dword /d 00000001 /f
exit
:noproxy
reg add
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t reg_dword /d 00000000 /f
exit
:test
ping
%TestIP%
pause
exit
<------代码结束------
加载中,请稍候......