美文网首页
Batch script reset windows proxy

Batch script reset windows proxy

作者: MrDecoder | 来源:发表于2022-06-23 15:53 被阅读0次
image.png
@ECHO OFF
:: Disable automatically detect settings
SET REG_NAME_HKLM_IS="HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings"
SET KEY_NAME_PROXY_SETTING_PERUSER="ProxySettingsPerUser"

:: Query settings value
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY %REG_NAME_HKLM_IS% /v %KEY_NAME_PROXY_SETTING_PERUSER%') DO SET "var1=%%B"
ECHO [HKLM]%KEY_NAME_PROXY_SETTING_PERUSER%=%var1%
IF "%var1%" == "0x0" (
    ECHO "Update proxy per user settings."
    REG ADD %REG_NAME_HKLM_IS% /v %KEY_NAME_PROXY_SETTING_PERUSER% /t REG_DWORD /d 1 /f
) else (
    ECHO "Skip update proxy per user settings."
)

SET REG_NAME_HKCU_IS="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
SET KEY_NAME_PROXY_ENABLE="ProxyEnable"
SET KEY_NAME_PROXY_SERVER="ProxyServer"

:: Query proxy server setting
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY %REG_NAME_HKCU_IS% /v %KEY_NAME_PROXY_ENABLE%') DO SET "var2=%%B"
ECHO [HKCU]%KEY_NAME_PROXY_ENABLE%=%var2%
IF "%var2%" == "0x1" (
    ECHO "Update proxy settings[HKCU]."
    REG ADD %REG_NAME_HKCU_IS% /v %KEY_NAME_PROXY_ENABLE% /t REG_DWORD /d 0 /f
    REG ADD %REG_NAME_HKCU_IS% /v %KEY_NAME_PROXY_SERVER% /t REG_SZ /d "" /f
) else (
    ECHO "Skip update proxy settings[HKCU]."
)

SET REG_NAME_HKLM_ISs="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY %REG_NAME_HKLM_ISs% /v %KEY_NAME_PROXY_ENABLE%') DO SET "var3=%%B"
ECHO [HKLM]%KEY_NAME_PROXY_ENABLE%=%var3%
IF "%var3%" == "0x1" (
    ECHO "Update proxy settings[HKLM]."
    REG ADD %REG_NAME_HKLM_ISs% /v %KEY_NAME_PROXY_ENABLE% /t REG_DWORD /d 0 /f
    REG ADD %REG_NAME_HKLM_ISs% /v %KEY_NAME_PROXY_SERVER% /t REG_SZ /d "" /f
) else (
    ECHO "Skip update proxy settings[HKLM]."
)

pause >nul

相关文章

网友评论

      本文标题:Batch script reset windows proxy

      本文链接:https://www.haomeiwen.com/subject/rscmvrtx.html