我目前有兩個批處理檔案:proxy_enable.bat
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 1 /f
和 proxy_disable.bat
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" ^
/v ProxyEnable /t REG_DWORD /d 0 /f
我只想制作一個 proxy_switch.bat 檔案,它是:
if (registry key is 0) (put it to 1) ELSE (put it to 0)
但我找不到讀取ProxyEnable密鑰的方法HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
uj5u.com熱心網友回復:
以下腳本應在每次運行時切換該值:
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set "Fnd=%SystemRoot%\System32\find.exe"
Set "Reg=%SystemRoot%\System32\reg.exe"
Set "Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set "Val=ProxyEnable"
Set "Typ=REG_DWORD"
%Reg% Query "%Key%" /V "%Val%" | %Fnd% "x0" 1>NUL && (
%Reg% Add "%Key%" /V "%Val%" /T %Typ% /D "1" /F 1>NUL
) || %Reg% Add "%Key%" /V "%Val%" /T %Typ% /D "0" /F 1>NUL
uj5u.com熱心網友回復:
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable" | find /i "0x0" && goto :set1
:set0
set it here to 0
goto :end
:set1
set it here to 1
:end
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/476369.html
標籤:批处理文件
