Jump to content
Sign in to follow this  
Cyclops

RegWrite a String fails

Recommended Posts

Cyclops

Hi,

wan't to use the following script to change a regentry, but writing fails. Hope anyone knows why? When i declare another var - like $writestring = "1234" - then it works. Hope you could help me. Thanks

$regread = RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings")
$splitstring = StringSplit ($regread, "")
$replacestring = StringSplit ($CmdLineRaw, "")
$splitstring[17] = $replacestring [1]
$splitstring[18] = $replacestring [2]
Dim $writestring
For $i = 1 To $splitstring[0]
    $writestring = $writestring & $splitstring[$i]
Next
RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings1", "REG_Binary", $writestring)

Cyclops


Sorry for my cruel english :D

Share this post


Link to post
Share on other sites
/dev/null

what's the value of $writestring before you write it?

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites
Cyclops

Hi,

thx for answer, but what do you mean? $writestring is the modified $regread, so i don't no where the problem is. Sorry, i haven't any idea

Cyclops


Sorry for my cruel english :D

Share this post


Link to post
Share on other sites
seandisanti

Hi,

wan't to use the following script to change a regentry, but writing fails. Hope anyone knows why? When i declare another var - like $writestring = "1234" - then it works. Hope you could help me. Thanks

$regread = RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings")
$splitstring = StringSplit ($regread, "")
$replacestring = StringSplit ($CmdLineRaw, "")
$splitstring[17] = $replacestring [1]
$splitstring[18] = $replacestring [2]
Dim $writestring
For $i = 1 To $splitstring[0]
    $writestring = $writestring & $splitstring[$i]
Next
RegWrite ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings1", "REG_Binary", $writestring)

Cyclops

<{POST_SNAPBACK}>

question...

it looks like you're trying to write a string (or number like 1234 from your example) as a binary value?

Share this post


Link to post
Share on other sites
Cyclops

Yes, i looked in the help and there i found that:

When writing a REG_BINARY key use a string of hex characters, e.g. the REG_BINARY value of 01,a9,ff,77 can be written by using the string "01A9FF77".

So i thougtm that i must only change it and then rewrite it... Between $regread and $writestring isn't a optical difference only the two changed strings...


Sorry for my cruel english :D

Share this post


Link to post
Share on other sites
seandisanti

Yes, i looked in the help and there i found that:

So i thougtm that i must only change it and then rewrite it...  Between $regread and $writestring isn't a optical difference only the two changed strings...

<{POST_SNAPBACK}>

you may want to check your values after read and before write, and make sure you're writing what you intend to. also you may want to verify that the value you're trying to assign is supposed to be a REG_BINARY....

Share this post


Link to post
Share on other sites
Jos

Yes, i looked in the help and there i found that:

So i thougtm that i must only change it and then rewrite it...  Between $regread and $writestring isn't a optical difference only the two changed strings...

<{POST_SNAPBACK}>

Like Kurt asked: What is the value of $writestring when doing the RegWrite() statement ? (if it doesn't contain a proper HEX value, the RegWrite() will fail)

Also check the returncode of RegWrite to see if its 0 or 1.

$rc = RegWrite()


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Cyclops

Life is cruel :whistle:

I testet with "RR" and that isn't really a reg_binary!

Thx...

Cyclops


Sorry for my cruel english :D

Share this post


Link to post
Share on other sites
seandisanti

Life is cruel :whistle:

I testet with "RR" and that isn't really a reg_binary!

Thx...

Cyclops

<{POST_SNAPBACK}>

happens to everyone... 0-F for hex

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×