把下面的做成bat脚本,参数自己设置就行了,可以截取其中一部分。我在公司和家里就用这个脚本切换
@title 公司IP设置并代理设置
@echo off
@rem 设定外网网络参数
set NIC="本地连接"
set IP="130.89.200.45"
set MASK="255.255.255.0"
set GW="130.89.200.254"
set DNS="172.16.9.60"
@rem 设定是否使用代理。0不用,1用
set DL=0
set DLIP="130.89.200.53:808"
set DLOVER="130.89.*.*;172.*.*.*;*.si-tech.*;*.17173.*;*.altova.*"
@rem 修改IP及DNS
@netsh interface ipv4 set address name=%NIC% source=static address=%IP% mask=%MASK% gateway=%GW%
@netsh interface ipv4 set dnsservers name=%NIC% source=static address=%DNS%
@rem 修改代理
if "%DL%"=="0" goto 0
if "%DL%"=="1" goto 1
:0
@echo Windows Registry Editor Version 5.00>代理.reg
@echo REGEDIT4>>代理.reg
@echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]>>代理.reg
@echo "ProxyEnable"=dword:00000001>>代理.reg
@echo "ProxyServer"=%DLIP%>>代理.reg
@echo "ProxyOverride"=%DLOVER%>>代理.reg
goto regDL
:1
@echo Windows Registry Editor Version 5.00>代理.reg
@echo REGEDIT4>>代理.reg
@echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]>>代理.reg
@echo "ProxyEnable"=dword:00000000>>代理.reg
goto regDL
:regDL
@regedit /s 代理.reg
msg %username% /time:2 恭喜,%NIC%设置成功!
del 代理.reg