Re: Editing the nth byte of a BINARY Registry Value
- From: "Dan Khanseitov" <dankh(nospam@)mail.ru>
- Date: Mon, 04 Apr 2005 22:13:40 +0700
Hi!
Example:
I need change binary value (one byte "0a" to "03" ) in key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"DaylightStart"=hex:00,00,0a,00,05,00,03,00,00,00,00,00,00,00,00,00
to the new value.
Script:
**************************************************************************************** const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")'Define byte's array Dim bArray
strKeyPath = "SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
'Fill array with values of the key; 'array elemnts starts from 0 an up, 'so I need to change bArray(2) element's value
objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, "DaylightStart", bArray
'Changing value bArray(2) = 3
'Write infromation back
objReg.SetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, "DaylightStart", bArray
Set objReg = Nothing
****************************************************************************************
Regards, Dan
Gary wrote :
Hello
I'm trying to edit a Binary Registry value which I can do by doing a full replace of the data, but because the data could be different from machine to machine and only specific bytes change I was trying to write a script that would allow me just edit specific bytes for example byte 6 and 63, but I don't know the best way to go about it.
Could I use to the Replace function in this example? Replace(reg_string, "00", "01", 63, 1, 0)
If so would someone be able be able to help me read in a binary registry value that I could run the replace on.
I really don't have any preference how I get to how I get this to work, my programming knowledge is limited so any advice or help would be most appreciated.
Thanks for time
Gary
PS My reference to a byte is if you export out from the registery a binary value eg "1"=hex:03,00,00,00,00,00,00,
I'm asuming that the number inbetween the coma's represets a byte and I've worked out byte's that I would need to change.
Please feel free to tell me if i'm being a doughnut
.
- Follow-Ups:
- References:
- Prev by Date: Enable / Disable 802.1x with some script
- Next by Date: RE: Scripting for local user admin
- Previous by thread: Editing the nth byte of a BINARY Registry Value
- Next by thread: Re: Editing the nth byte of a BINARY Registry Value
- Index(es):