Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reg file to change a specific bit in a specific key

Posted on 2013-02-04
3
Medium Priority
?
757 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 1000 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 1000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. 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…

715 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