Solved

Reg file to change a specific bit in a specific key

Posted on 2013-02-04
3
734 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

Title # Comments Views Activity
Graphics card for a new Dell 5810 workstation 16 107
DVD or CD-Rom Useage history in Windows event viewers 8 36
FireFox Add-on Plugins 3 26
Non admin needs to install programs 17 35
OfficeMate Freezes on login or does not load after login credentials are input.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

777 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