Solved

Reg file to change a specific bit in a specific key

Posted on 2013-02-04
3
733 Views
Last Modified: 2013-02-24
Hi,

I want to remove the IE option of "Use automatic configuration script" via a batch or reg file.
I already found where this checkbox is in in the registry.

9th bit of this key :
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections] "DefaultConnectionSettings"

How can I make this change from a reg or batch file? I don't want to export the entire "Connections" container because it contains other keys as well that might chagne other system behavior. and I also want to share this solution (be it a reg file or other) with my colleagues, so they shouldn't get settings from my machine. best way would be to change the specific bit from 05 to 01.

Thanks
0
Comment
Question by:shootbox
3 Comments
 
LVL 9

Accepted Solution

by:
EMJSR earned 250 total points
ID: 38853862
I have attached a .reg file (rename extension back to .reg) that will change the ninth bit accordingly. Only the listed key will be imported and changed, nothing else. To do this from a batch file, you can use the following command:

reg import connections.reg

Open in new window

You can obviously specify a path, too, such as...
reg import \\server\network\location\import.reg

Open in new window

etc.
connections.reg.txt
0
 
LVL 4

Expert Comment

by:Thomas WERNHER
ID: 38853992
use the reg add from the cli.

btw, maybe a GPO would do it...?

Cheers.
T
0
 
LVL 83

Assisted Solution

by:oBdA
oBdA earned 250 total points
ID: 38854057
That's actually not the 9th bit, but the 9th byte that you want to change.
Anyway, try the batch script below; it's currently in test mode and will only display the "reg add" command it would normally run. Remove the uppercase "ECHO" in front of "reg.exe add" in line 29 to run it for real.
@echo off
setlocal enabledelayedexpansion
set RegKey=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
set RegVal=DefaultConnectionSettings
echo Reading current settings ...
for /f "tokens=2*" %%a in ('reg.exe query "%RegKey%" /v "%RegVal%" ^| find /i "%RegVal%"') do (set RegData=%%~b)
set /a ByteCount = 0
:StringToByteArrayLoop
	set /a ByteCount += 1
	set Byte[!ByteCount!]=!RegData:~0,2!
	set RegData=!RegData:~2!
if not "!RegData!"=="" (goto :StringToByteArrayLoop)
echo ... found %ByteCount% entries.
for /f "tokens=1 delims=[]" %%a in ('type "%~f0" ^| find /n "[REPLACE]"') do set DataStart=%%a
for /f "skip=%DataStart% tokens=1* delims== " %%i in ('type "%~f0"') do (
	if %%i gtr %ByteCount% (
		echo Replacement index %%i is outside of the length of the current data ^(%ByteCount%^).
		echo Operation cancelled.
		goto :eof
	)
	set NewValue=0%%j
	set NewValue=!NewValue:~-2!
	echo Byte[%%i]: !Byte[%%i]! --^> !NewValue!
	set Byte[%%i]=%%j
)
echo Writing settings back to registry ...
set RegData=
for /l %%i in (1, 1, %ByteCount%) do (set RegData=!RegData!!Byte[%%i]!)
ECHO reg.exe add "%RegKey%" /v "%RegVal%" /t REG_BINARY /d "%RegData%" /f
echo Done.

goto :eof
REM In the following section, enter the bytes to be replaced in the format <Index>=<NewValue>;
REM Index is one-based, not zero-based!
REM NewValue is the new hex value without leading "0x".
REM Leading zeros for the index are not allowed; for the value, leading zeros can be added, but are not required.
REM Example: 9=5 or 12=0C
[REPLACE]
9=05

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now