在批处理文件中检查 ProxyEnable
check ProxyEnable in a batch file
我目前有两个批处理文件:
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)
但我找不到读取 HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
中的 ProxyEnable
键的方法
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
以下脚本应该切换值,每次都是 运行:
@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
我目前有两个批处理文件: 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)
但我找不到读取 HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
ProxyEnable
键的方法
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
以下脚本应该切换值,每次都是 运行:
@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