Page 1 of 1 1
Topic Options
#93479 - 2002-09-05 08:59 PM Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
I need to edit a binary registry entry on all of the PC's on my network but I only need to edit one small value in this entry (changes screen refresh updates from 100 (64) to 10 (0A).

I am using the Writevalue command but the rest of the binary entry is unique to each computer so I cannot modify that. I do not seem to have the flexibility to edit only the one specific piece of the binary entry. The entry is in the same spot in the binary entry on every pc. Is there another command I can use!! Can this even be done...someone help!!!

Top
#93480 - 2002-09-05 09:03 PM Re: Editing Binary files in the registry using writevalue
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
My suggestion would be to read in the entire value as a string, then use LEFT(),RIGHT(), and/or SUBSTR() to overwrite the old data with the new data before writing the value back to the registry. There is probably a script floating around that will do this (I think I wrote one a long time back.. don't know where it is), but it shouldn't be too difficult, in concept, as long as you know the exact number of characters before each bit of information you put into the string.

Brian

[ 05. September 2002, 21:04: Message edited by: BrianTX ]

Top
#93481 - 2002-09-05 09:09 PM Re: Editing Binary files in the registry using writevalue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I would be really careful changing the screen refresh rate indiscriminantly. You might set it to a value that the monitor and/or graphics card do not support.
_________________________
There are two types of vessels, submarines and targets.

Top
#93482 - 2002-09-05 09:28 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
The refresh rate is not actually for the monitor...it's for a program called Remote Administrator (kinda like pcanywhere). They have not put out a video hook driver yet for w2k (without it the cpu gets killed on the remote machine) and their answer to fix the problem is to reduce the refreshes per second from 10 to 100. The problem is that every pc on the network uses 100 so I need to change every pc's refreshes in this program to 10.
Top
#93483 - 2002-09-05 09:49 PM Re: Editing Binary files in the registry using writevalue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, I know this program, I and a couple of other in this BBS are already using it. I even wrote remote install script for it. IIRC, you only need to change the registry entries on those computers that have the viewer installed, which hopefully will not be every computer on your network but only select admin workstations.
_________________________
There are two types of vessels, submarines and targets.

Top
#93484 - 2002-09-05 10:06 PM Re: Editing Binary files in the registry using writevalue
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Jooel's TaskBar() UDF does a readvalue on a binary key to extract the height of the taskbar. Perhaps this method can be converted to write a binary value.

Here's the code...

code:
Function TaskBar()
if @dos=="4.0" $_S="StuckRects" else $_S="StuckRects2" endif
$TaskBar=val("&"+substr(readvalue("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\$_S","settings"),41,2))
endfunction


Top
#93485 - 2002-09-06 12:01 AM Re: Editing Binary files in the registry using writevalue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah, actually it already does it.

it writes a binary value to change the place where the taskbar resides.

 
_________________________
!

download KiXnet

Top
#93486 - 2002-09-06 05:25 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
First off...thanks to everyone who has been helping in advance...I am kinda new to kixstart and your help is well appreciated.

I am able to extract the Binary value from the string using the following code:

dim $x,$Binary

$x = readvalue("HKCU\Software\radmin\v2.0\clients","2")
? "Binary Value = $x"
$Binary=val("&"+substr("$x", 29,2))
? "Binary=$Binary"

But once I actually extract them how do I change them to what I want (from 100 to 10)and get them back into the string without changing the rest of the string. I basically just want to insert 0a in place of 64 in this string and then write it back into the registry using writevalue. Help!!

Top
#93487 - 2002-09-06 05:39 PM Re: Editing Binary files in the registry using writevalue
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Silver, I'm sorry, I gave you incomplete code. Go here and look at how Jooel did it in his TaskBar() UDF.
Top
#93488 - 2002-09-06 05:43 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
This actually works but it is just so damn ineffecient

dim $x,$A,$B,$C,$Binary

$x = readvalue("HKCU\Software\radmin\v2.0\clients","2")
? "Binary Value = $x"
$A=substr("$x", 1,28)
$B=0a
$C=substr("$x", 31)
$Binary=$A+$B+$C

...I'll look over Joel's and see how he did this.
Thanks

Top
#93489 - 2002-09-06 06:28 PM Re: Editing Binary files in the registry using writevalue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah, it is just matter of:
code:
$x = readvalue("HKCU\Software\radmin\v2.0\clients","2")
$changedX = left($x,28)+"0a"+substr($x, 31)

don't know about efficiency, but that's how I did that...
 

[ 06. September 2002, 18:29: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#93490 - 2002-09-06 06:54 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
Ok....everything seems to be working from the string standpoint (thanks to all that helped..that part looks good now). My last problem is that in the registry the number "2" at the end of this statement:

$V=("HKCU\Software\radmin\v2.0\clients","2")

Represents a single Remote Access connection...ie one computer I have connected to in Remtoe Administrator. I need to change the refreshes for every computer in the registry (some PC's may only have "1","2","3" entries and others may have up to 150. How can I change that "2" to represent the next computer entry in the registry???

PS- when this is finished I will post the complete code for this for refrence purposes!!

Top
#93491 - 2002-09-06 06:59 PM Re: Editing Binary files in the registry using writevalue
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I think your question is: "how do I enum through a key and set values?"

Check this thread for details, How Do I locate and use the next available registry value

Top
#93492 - 2002-09-06 08:10 PM Re: Editing Binary files in the registry using writevalue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And download the ArrayEnumValue() UDF which returns an array of registry values for a specific registry key. Your code would look like:
code:
$regkey='HK_CURRENT_UUSER\Software\radmin\v2.0\clients'
$regvalues=ArrayEnumValue($regkey)
for each $value in $regvalues
$content = readvalue($regkey,$value)
$content = left($content,28)+'0A'+substr($content, 31)
$rc = writevalue($regkey,$value,$content,'REG_SZ')
next



[ 06. September 2002, 22:10: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#93493 - 2002-09-06 10:03 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
I am not real familiar with the UDF's as I am new to kixstart and never used them before....I am running the script the way I think it should be run but I am sure it is wrong because it is not producing the results...here is my code:

Break on
dim $Regkey,$X,$changedx,$Value

? "Version Check"

If Keyexist("HKCU\Software\radmin\v2.0") or ("HKCU\Software\radmin\v2.1")
goto RAGOOD
Else
Exit
End IF

:RAGOOD
If Keyexist("HKCU\Software\radmin\v2.0")
$Regkey="HKCU\Software\radmin\v2.0\clients"
else
$Regkey="HKCU\Software\radmin\v2.1\clients"
EndIf

function arrayenumvalue($regsubkey)
dim $retcode, $valuecounter, $currentvalue, $valuearray
if not keyexist($regsubkey)
$arrayenumvalue=''
return
endif

$valuecounter=0
do
$currentvalue=enumvalue($regsubkey,$valuecounter)
if $currentvalue<>259 and @ERROR=0
redim preserve $valuearray[$valuecounter]
$valuearray[$valuecounter]=$currentvalue
$valuecounter=$valuecounter+1
endif
until $currentvalue=259 or @ERROR

$arrayenumvalue=$valuearray
endfunction

$regvalues=ArrayEnumKey($regkey)
for each $value in $regvalues
$content = readvalue($regkey,$value)
$content = left($content,28)+'0A'+substr($content, 31)
$rc = writevalue($regkey,$value,$content,'REG_Binary')
next

:Exit
quit

I am almost positive I am using this function wrong "Jens". can you describe how I should use this.

Top
#93494 - 2002-09-06 10:13 PM Re: Editing Binary files in the registry using writevalue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please take a look at the example I provided and read How to use UDFs .

Please notye that I just corrected a spelling error in my example code, the function call is ArrayEnumValue and I wrote ArrayEnumKey, which will not work. I have corrected my example code acordingly.
_________________________
There are two types of vessels, submarines and targets.

Top
#93495 - 2002-09-06 10:16 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
I thought that looked funny...will read and thanks for the help!!
Top
#93496 - 2002-09-06 10:30 PM Re: Editing Binary files in the registry using writevalue
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
Thanks to everyone for their help with this...the script seems to be working like a charm now. I had writtent the original script using a loop and got a wierd "cannot read registry entry" when opening up RA. I took Jens suggestion and tried using the ArrayEnumValue () UDF and it worked like a charm. Here is a final posting of the code that works:

Break on
dim $Regkey,$X,$changedx,$Value

? "Version Check"

If Keyexist("HKCU\Software\radmin\v2.0") or ("HKCU\Software\radmin\v2.1")
goto RAGOOD
Else
Exit
End IF

:RAGOOD
If Keyexist("HKCU\Software\radmin\v2.0")
$Regkey="HKCU\Software\radmin\v2.0\clients"
else
$Regkey="HKCU\Software\radmin\v2.1\clients"
EndIf

$regvalues=ArrayEnumValue($regkey)
for each $value in $regvalues
$content = readvalue($regkey,$value)
$content = left($content,28)+'0A'+substr($content, 31)
$rc = writevalue($regkey,$value,$content,'REG_Binary')
next
exit

function arrayenumvalue($regsubkey)
dim $retcode, $valuecounter, $currentvalue, $valuearray
if not keyexist($regsubkey)
$arrayenumvalue=''
return
endif

$valuecounter=0
do
$currentvalue=enumvalue($regsubkey,$valuecounter)
if $currentvalue<>259 and @ERROR=0
redim preserve $valuearray[$valuecounter]
$valuearray[$valuecounter]=$currentvalue
$valuecounter=$valuecounter+1
endif
until $currentvalue=259 or @ERROR

$arrayenumvalue=$valuearray
endfunction

Thanks again everyone!!

Top
#93497 - 2002-09-06 11:01 PM Re: Editing Binary files in the registry using writevalue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
BTW, you might want to post your code between [CODE] tags, this will retain formatting.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1160 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.071 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org