如標(biāo)題,直接上代碼:
@echo off
echo 參數(shù)說明:q 是離開; o (歐) 是使用上一次的代理數(shù)據(jù),輸入處沒有顯示:即沒有歷史數(shù)據(jù); c 是清空代理; ip:port 按照此格式可以設(shè)置代理
if not exist %temp%\myproxy (
md %temp%\myproxy
)
if not exist %temp%\myproxy\r.txt (
set /p flag="please enter c/ip:port/q->"
)^
else (
set /p flag="please enter c/ip:port/q/o->"
)
if /i %flag% == c (
echo 正在清空代理服務(wù)器設(shè)置……
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
echo 代理服務(wù)器設(shè)置已經(jīng)清空
)^
else (
if /i %flag% == q (
echo 關(guān)閉
)^
else (
if /i %flag% == o (
if not exist %temp%\myproxy\r.txt (
echo 沒有歷史記錄
pause
)^
else (
set /p firstRow=<"%temp%\myproxy\r.txt"
echo 正在設(shè)置代理服務(wù)器……
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "%firstRow%" /f
echo 設(shè)置完畢
)
)^
else (
echo %flag% > %temp%\myproxy\r.txt
echo 正在設(shè)置代理服務(wù)器……
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "%flag%" /f
echo 設(shè)置完畢
)
)
)
更新:
發(fā)現(xiàn)設(shè)置后,沒有實(shí)時更新,還是需要打開系統(tǒng)的配置頁面才能刷新,研究發(fā)現(xiàn)還需要考慮:
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
正在理解中。。。