NiVZ Posted August 11, 2009 Posted August 11, 2009 (edited) Hello, I'm trying to modify a BINARY registry value to turn on or off the "Automatically Detect Settings" in IE. I've searched the web and found I need to modify a binary key at: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings" But I'm useless at Binary. I found this VBScript that does what I need, but I want to do this in Autoit: DIM sKey,sValue,binaryVal Dim oReg Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") 'For registry operations througout Const HKCU=&H80000001 sKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" sValue = "DefaultConnectionSettings" oReg.GetBinaryValue HKCU, sKey, sValue, binaryVal select case lcase(status) case "on" binaryVal(8) = binaryVal(8) OR 8 'Force Autodetect on case "off" binaryVal(8) = binaryVal(8) XOR 8 'Force Autodetect off case "show" wscript.echo "Automatically detect is set to " & ((binaryVal(8) and 8) = 8) case else wscript.echo "Invalid parameter - IEautomaticallydetect on, off or show" end select So far I've got: ; Get The Registry Value $Reg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings") ; Show the value we want to modify MsgBox(0,"1",BinaryMid($Reg, 9, 1)) ; Show the value we want to add or subtract to turn on or off MsgBox(0,"2",Binary("0x08")) But now I'm stuck as I don't know how to BitOR or BitXOR just the 8th (counting from zero) pair of bytes (in the way the VB code deos it with BinaryVal(8). Any help appreciated. Thanks, NiVZ Edited August 11, 2009 by NiVZ
JScript Posted August 13, 2009 Posted August 13, 2009 I tried this and it worked as expected:; Get The Registry Value $bReg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings") $iSearch = 9 ;the value we want to modify $iReplace = 8 ;The value we want to replace $iExample1 = StringReplace($bReg, StringInStr($bReg, $iSearch), $iReplace, 1) If Not @error Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings", "REG_BINARY", $iExample1) MsgBox(4096, "Example1", $iExample1) $iSearch = 8 ;the value we want to modify $iReplace = 9 ;The value we want to replace $iExample2 = StringReplace($iExample1, StringInStr($iExample1, $iSearch), $iReplace, 1) If Not @error Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings", "REG_BINARY", $iExample2) MsgBox(4096, "Example2", $iExample2)Be careful when doing alterations in the Windows registry http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Reveal hidden contents Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
wporter Posted March 9, 2011 Posted March 9, 2011 The problem with this solution is that if the Automatically detect proxy setting is already off, another section of the data will be modified. There is a section before that increments as well, and can be modified by accident if it reaches the number being searched. The clean way would be to modify the 8th byte as in the code example posted at first. I am searching for a way to do this, but so far have not found what I'm looking for. I know it's got to be something obvious that I just don't see right now.
ProgAndy Posted March 10, 2011 Posted March 10, 2011 What about: $data = RegRead... $chunk1 = BinaryMid($data, 1,7) $chunk2 = BinaryMid($data, 9) $result = $chunk1 & _Modify(BinaryMid($data, 8, 1)) & $chunk2 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
wporter Posted March 10, 2011 Posted March 10, 2011 (edited) This is what I actually ended up doing: $reg = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings") $regupd = BinaryMid($reg, 1, 8) & Binary("0x01") & BinaryMid($reg, 10) RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections","DefaultConnectionSettings","REG_BINARY",$regupd) Edited March 10, 2011 by wporter
DarkLordZim Posted August 9, 2011 Posted August 9, 2011 I just wanted to say thank you, i've been trying to do this for a very looooooong time.I had found this thread in another forum for where the registry values needed are one of the posts in there revealed the following Binary values and what boxes would be checked. Quote 3) Byte number 8 can take different values as per your settings. The value is : 09 when only 'Automatically detect settings' is enabled 03 when only 'Use a proxy server for your LAN' is enabled 0B when both are enabled 05 when only 'Use automatic configuration script' is enabled 0D when 'Automatically detect settings' and 'Use automatic configuration script' are enabled 07 when 'Use a proxy server for your LAN' and 'Use automatic configuration script' are enabled 0F when all the three are enabled.01 when none of them are enabled. The next three bytes are zeros (Bytes 9 to B ).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now