Batch file script for Enable & disable the "use automatic Configuration Script"

Posted by Tijo Joy on Super User See other posts from Super User or by Tijo Joy
Published on 2012-10-16T10:29:12Z Indexed on 2012/10/16 11:07 UTC
Read the original article Hit count: 1226

Filed under:
|
|

My intention is to create a .bat file that toggles the check box of "use automatic Configuration Script" in Internet Settings.

The following is my script

@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
)

The output i'm getting for the Proxy Enabled part is

Value Name = AutoConfigURL
Value Type = REG_SZ
**Value Value =yyyy**
 Hai
The operation completed successfully.
Proxy Disabled

But the Proxy Enable part isn't working fine the output i get is :

Value Name = AutoConfigURL
Value Type = REG_SZ
**Value Value =**
( was unexpected at this time.
The variable "Value Value" is not getting set when we try to do the Proxy enable

© Super User or respective owner

Related posts about Windows

Related posts about script