RegWrite Question
#1
Posted 18 November 2004 - 09:21 PM
I have tried using Opt(ExpandEnvStrings, 1/0) to no avail. Any help would be appreciated!
#2
Posted 18 November 2004 - 09:25 PM
why first convert it and then change it back to %systemdrive% ?I am attempting to read in a reg value, append some data to that value and the write it back to the same key. The data I'm reading is contains Env. Variables such as %systemdrive%. When I read it into a variable, autoit converts it to the literal or C:\. I can work around this by doing a string replace, but when I do a RegWrite, I get C:\ back into the registry. Any ideas how to get Rewrite to write %systemdrive% instead of C:\?
I have tried using Opt(ExpandEnvStrings, 1/0) to no avail. Any help would be appreciated!
maybe you can explain what you want to accomplish and post what you have ?
Visit the SciTE4AutoIt3 Download page for the latest versions Forum Rules
Live for the present,
Dream of the future,
Learn from the past.
#3
Posted 18 November 2004 - 09:31 PM
I'm not trying to convert it actually. RegRead and RegWrite are converting it for me... Anyway I'm trying to read in the "Path" info, which contains Env. Variables, specifically, %systemdrive%. I want to write back to the registry what I read out, not C:\.why first convert it and then change it back to %systemdrive% ?
maybe you can explain what you want to accomplish and post what you have ?
Thanks.
#4
Posted 18 November 2004 - 09:31 PM
Script I tested:
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "%windir%") $a = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") MsgBox(0,'',$a)
What OS are you using?
#5
Posted 18 November 2004 - 09:32 PM
I get %systemdrive% returned
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "%systemdrive%") $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") MsgBox(1,"",$var)
#6
Posted 18 November 2004 - 09:37 PM
I must be retarded then. I have XP Pro SP1 installed on this packaging machine. Not sure what the deal is. The only thing I see here is that you are creating the key, and I'm overwriting one that is already created. They key type is a bit different too, yours being REG_SZ, mine being REG_EXPAND_SZ. Test it with that key type and let me know.Funny, does this show %systemdrive% or c:\
I get %systemdrive% returnedRegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "%systemdrive%") $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") MsgBox(1,"",$var)
Thanks.
#7
Posted 18 November 2004 - 09:44 PM
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_EXPAND_SZ", "DoomedKey") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_EXPAND_SZ", "%windir%");So it overwrites. $a = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") MsgBox(0,'',$a)
cmacrun can you try OURS script?
(mine will delete the key so you wont leave a trace...)
Edited by ezzetabi, 18 November 2004 - 09:49 PM.
#8
Posted 18 November 2004 - 09:47 PM
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey1", "REG_EXPAND_SZ", "%systemdrive%") $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey1") MsgBox(1,"",$var)
test your code first by displaying what was read, and rigth before you put it back. I am thinking your script is converting it when you process it.
Edited by scriptkitty, 18 November 2004 - 10:02 PM.
#9
Posted 18 November 2004 - 10:09 PM
I read what is there, and overwrite it, and then read it again.
$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent") MsgBox(1,"Test1",$var) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent", "REG_EXPAND_SZ", $var) $var2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent") MsgBox(1,"Test2",$var2)
Just to make sure, I changed it to test and wrote the original back.
$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent") MsgBox(1,"Test1",$var) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent", "REG_EXPAND_SZ", $var & "1") $var2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent") MsgBox(1,"Test2",$var2) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Recent", "REG_EXPAND_SZ", $var)
#10
Posted 18 November 2004 - 10:10 PM
Ok this is strange, when I look at the actual registry value, it shows %systemdrive%, but when I go through system properties, it shows C:\. This was not happening prior to running the script, so it must be something with the way the OS is processing the key after being modified. Go figure. Thanks for the prompt responses on this. Sorry for the false alarm!No change. What about on yours?
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey1", "REG_EXPAND_SZ", "%systemdrive%") $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey1") MsgBox(1,"",$var)
test your code first by displaying what was read, and rigth before you put it back. I am thinking your script is converting it when you process it.
#11
Posted 18 November 2004 - 10:53 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users




