浏览模式: 标准 | 列表 2022年11月22日的文章

【转】批处理开启/关闭系统代理

@echo off

for /f "tokens=1,2,* " %%i in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable ^| find /i "ProxyEnable"') do (set /A ProxyEnableValue=%%k)

if %ProxyEnableValue% equ 0 (

    echo 系统代理目前处于关闭状态,正在开启代理,请稍候...

    echo=

    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f >nul 2>nul

    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "IP:PORT" /f >nul 2>nul

    echo 系统代理已开启,请按任意键关闭本窗口...

) else if %ProxyEnableValue% equ 1 (

    echo 系统代理目前处于开启状态,正在关闭代理,请稍候...

    echo=

    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f >nul 2>nul

    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f >nul 2>nul

    echo 系统代理已关闭,请按任意键退出本窗口...

)

pause>nul