cmacrun Posted November 18, 2004 Share Posted November 18, 2004 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! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 18, 2004 Developers Share Posted November 18, 2004 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!<{POST_SNAPBACK}>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 ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
cmacrun Posted November 18, 2004 Author Share Posted November 18, 2004 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 ?<{POST_SNAPBACK}>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:\. Thanks. Link to comment Share on other sites More sharing options...
ezzetabi Posted November 18, 2004 Share Posted November 18, 2004 I just tried and I don't have this problem. 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? Link to comment Share on other sites More sharing options...
scriptkitty Posted November 18, 2004 Share Posted November 18, 2004 Funny, does this show %systemdrive% or c:\ I get %systemdrive% returned RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "%systemdrive%") $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey") MsgBox(1,"",$var) AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
cmacrun Posted November 18, 2004 Author Share Posted November 18, 2004 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)<{POST_SNAPBACK}>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.Thanks. Link to comment Share on other sites More sharing options...
ezzetabi Posted November 18, 2004 Share Posted November 18, 2004 (edited) No difference: 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 November 18, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
scriptkitty Posted November 18, 2004 Share Posted November 18, 2004 (edited) 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. Edited November 18, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scriptkitty Posted November 18, 2004 Share Posted November 18, 2004 Ok, on win2k, I found a few env variables. Works fine here with this code. 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) AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
cmacrun Posted November 18, 2004 Author Share Posted November 18, 2004 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.<{POST_SNAPBACK}>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! Link to comment Share on other sites More sharing options...
this-is-me Posted November 18, 2004 Share Posted November 18, 2004 Glad I saw this... You can't change the _actual_ systemdrive variable in the registry, because windows knows better. You can, however do a subst from the command line to create a new drive letter for an existing drive. Who else would I be? Link to comment Share on other sites More sharing options...
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