This commit is contained in:
Yuhang Zhao 2023-09-11 18:10:36 +08:00
parent f793ab6952
commit f6544ecb13
2 changed files with 28 additions and 6 deletions

View File

@ -21,6 +21,17 @@
:: SOFTWARE.
@echo off
set HTTP_PROXY=http://127.0.0.1:4780
set HTTPS_PROXY=http://127.0.0.1:4780
set ALL_PROXY=http://127.0.0.1:4780
for /f "tokens=1,2,*" %%i in ('reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable') do set __proxy_enable=%%k
for /f "tokens=1,2,*" %%i in ('reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer') do set __proxy_server=%%k
if /i "%__proxy_enable%" == "0x1" (
set HTTP_PROXY=http://%__proxy_server%
set HTTPS_PROXY=http://%__proxy_server%
set ALL_PROXY=http://%__proxy_server%
) else (
set HTTP_PROXY=
set HTTPS_PROXY=
set ALL_PROXY=
)
echo HTTP_PROXY=%HTTP_PROXY%
echo HTTPS_PROXY=%HTTPS_PROXY%
echo ALL_PROXY=%ALL_PROXY%

View File

@ -20,6 +20,17 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
$env:HTTP_PROXY="http://127.0.0.1:4780"
$env:HTTPS_PROXY="http://127.0.0.1:4780"
$env:ALL_PROXY="http://127.0.0.1:4780"
$__proxy_enable = Get-ItemPropertyValue "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" "ProxyEnable"
$__proxy_server = Get-ItemPropertyValue "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" "ProxyServer"
if ($__proxy_enable -eq 1) {
$env:HTTP_PROXY="http://$__proxy_server"
$env:HTTPS_PROXY="http://$__proxy_server"
$env:ALL_PROXY="http://$__proxy_server"
} else {
$env:HTTP_PROXY=""
$env:HTTPS_PROXY=""
$env:ALL_PROXY=""
}
Write-Host "HTTP_PROXY:" $env:HTTP_PROXY
Write-Host "HTTPS_PROXY:" $env:HTTPS_PROXY
Write-Host "ALL_PROXY:" $env:ALL_PROXY