I'm trying to create a bat file to toggle the automatic configuration script checkbox in Internet Explorer (see red box in screenshot)…but without removing any existing value in the related textbox (see green box in screenshot).
I checked here: Batch file script for Enable & disable the "use automatic Configuration Script"
But that script a) removes existing values and b) seems to only disable he checkbox and never enable it.
@echo OFF
setlocal ENABLEEXTENSIONS
set KEY_NAME="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set VALUE_NAME=AutoConfigURL
FOR /F "usebackq skip=1 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
set ValueName=%%A
set ValueType=%%B
set ValueValue=%%C
)
@echo Value Name = %ValueName%
@echo Value Type = %ValueType%
@echo Value Value = %ValueValue%
IF NOT "%ValueValue%"=="yyyy" (
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "yyyy" /f
echo Proxy Enabled
) else (
echo Hai
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d "" /f
echo Proxy Disabled
)
pause
What am I missing here?
Best Answer
I know this is an old question, but it was not so easy for me to find a solution so I want to share what I found with you just in case you land in this page.
In the RegKey
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
the 9th value ofDefaultConnectionSettings
store the flag of:Available values:
01 - neither of those 2 auto config boxes are checked
05 - just the Use automatic configuration script is checked
09 - just the Automatically detect settings is checked
0d - both of them are checked
Personally I exported the current key, I created a copy and modified it with the text editor.
Then on needs I load through Command Line the initial RegKey or the modified one through command
reg import KeyIWantToUse.reg
Thanks to Jamie Google Group And to Leo on StackOverflow that helped me a lot.