+
95
-

回答

通过bat修改注册表

@echo off

:: 设置代理服务器地址和端口号
set "proxyServer=proxy.example.com:8080"

:: 启用或禁用代理(1表示启用,0表示禁用)
set "enableProxy=1"

:: 设置代理类型,1为HTTP代理,2为SOCKS代理
set "proxyType=1"

:: 设置白名单,即允许代理的网站列表
set "whitelist=example.com;subdomain.example.com"

:: 修改代理设置
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d %enableProxy% /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d "%proxyServer%" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "%whitelist%" /f

:: 通知系统更新代理设置
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxySettingsPerUser /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v MigrateProxy /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d %enableProxy% /f

:: 刷新系统设置
"%windir%\System32\cmd.exe" /c %windir%\System32\rundll32.exe "%windir%\System32\shell32.dll",Control_RunDLL "%windir%\System32\inetcpl.cpl",Connections,4

关闭代理

@echo off

:: 将代理服务器地址和端口号设置为空
set "proxyServer="

:: 设置启用代理为 0 (禁用代理)
set "enableProxy=0"

:: 修改代理设置
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d %enableProxy% /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d "%proxyServer%" /f

:: 通知系统更新代理设置
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxySettingsPerUser /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v MigrateProxy /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d %enableProxy% /f

:: 刷新系统设置
"%windir%\System32\cmd.exe" /c %windir%\System32\rundll32.exe "%windir%\System32\shell32.dll",Control_RunDLL "%windir%\System32\inetcpl.cpl",Connections,4

网友回复

我知道答案,我要回答