Solved

Reg file to change a specific bit in a specific key

Posted on 2013-02-04
3
746 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 85

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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

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…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

717 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