使用批量指令cmd創(chuàng)建bat修改windows的http代理

如標(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
正在理解中。。。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容