IE代理可以在注冊表中設置,所以用DOS修改注冊表,可以達到目的.
方法一:
注冊表文件:
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
"ProxyServer"="192.168.0.1:8088"
"ProxyOverride"="192.168.*"
保存為reg文件,如proxy.reg,然后在DOS中,導入注冊表:
regedit /s proxy.reg
方法二:
使用bat腳本處理
@echo off echo 【修改IE】 rem “是否啟用本地IE代理設置,值為1表示啟用,勾選“為LAN使用代理服務器”前面的勾,值為0表示禁用,則不會勾選上 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f rem “設置代理服務器地址和端口號 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "12.123.12.12:8080" /f rem “對於本地地址不使用代理服務器”這個勾,不會勾選上 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "11.*;68.*;10.*;" /f rem “對於本地地址不使用代理服務器”這個勾,會勾選上 ::reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "11.*;68.*;10.*;<local>" /f
其中最下面的兩行已經做了說明,我就不解釋了。如下圖
參考:
http://zhidao.baidu.com/question/42517242.html
http://zhidao.baidu.com/question/349423330.html
=================================================================================
根據上面的知識,我寫了個啟用或禁用IE代理的腳步,方便在家里和公司的環境進行切換,代碼如下
@echo off echo 【修改IE代理設置】 set /p var=是否啟用IE代理設置[Y/N]: if /i %var%==Y (goto ProxyEnable) else (goto ProxyDisable) :ProxyEnable reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f echo 你已啟用IE代理 goto end :ProxyDisable reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f echo 你已禁用IE代理 goto end :end Pause