joseLB Posted October 6, 2019 Posted October 6, 2019 (edited) Hi This piece of code creates and reads OK a key at "HKEY_LOCAL_MACHINE" and can be changed for a key at "HKEY_CURRENT_USER" $sta= RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor", "wav", "REG_SZ", "5555") MsgBox(4096,"wrote", $sta &@cr& @error) $zz= RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor", "wav") MsgBox(4096,"readed","="&$zz &@cr& @error) Exit With HKEY_CURRENT_USER, in RegEdit we can see the created key, and we can create the key by hand/RegEdit and everything Works OK. At HKEY_LOCAL_MACHINE we can´t see the created key above thru RegEdit, but it Works (even not seeing, I can read). But if I create "by hand"/RegEdit the key, it can´t read it with $zz= RegRead ("HKEY_LOCAL_MACHINE.... above. I´m the PC´s WIN.7 administrator. Even so I ran RegEdit as administrator and also the compiled AU3 and also plain. No changes. edit: even if Try "HKEY_LOCAL_MACHINE\SOFTWARE\AAA", "wav", the same holds true. $sta= RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AAA", "wav", "REG_SZ", "4444") MsgBox(4096,"wrote", $sta &@cr& @error) $zz= RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\AAA", "wav") MsgBox(4096,"readed","="&$zz &@cr& @error) Exit Seems that it creates this key at another place.... I can read the above value ("4444"), even after a boot, even the key not showing in regedit. And if I create it by hand key AAA/wav with a distinct value (666), t, it continues Reading the old value = 444. Thanks Jose Edited October 6, 2019 by joseLB
Factfinder Posted October 6, 2019 Posted October 6, 2019 (edited) Hi, Is your Windows a x64-bit Windows? if that is the case your script creates and reads the value under x86 key and you won't be able to see the key under x64. The script will create the key and you will see it if you compile your script as x64-bit. Edited October 6, 2019 by Factfinder joseLB 1
Factfinder Posted October 6, 2019 Posted October 6, 2019 If you want to run the script without compiling it as an x64-bit executive, or if you compile it as an x86-bit executive, in your key use HKLM64\... instead of HKLM\... in your script. joseLB 1
Subz Posted October 6, 2019 Posted October 6, 2019 As @Factfinder mentioned: Script compiled as 32-bit on a 64-bit Operating System To access 32-Bit Hive - HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node use:HKLMTo access 64-Bit Hive - HKEY_LOCAL_MACHINE use:HKLM64 Script compiled as 64-bit on a 64-bit Operating System: To access 32-Bit Hive - HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node use:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NodeTo 64-Bit Hive - HKEY_LOCAL_MACHINE use:HKEY_LOCAL_MACHINE I normally use the following in my scripts: Global $g_sHKLM32 = @AutoItX64 ? "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node" : "HKLM" Global $g_sHKLM64 = @AutoItX64 ? "HKEY_LOCAL_MACHINE" : "HKLM64" Global $g_sProgramFilesDir32 = RegRead($g_sHKLM32 & "\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") ConsoleWrite("32-Bit Program Files Directory: " & $g_sProgramFilesDir32 & @CRLF) Global $g_sProgramFilesDir64 = RegRead($g_sHKLM64 & "\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") ConsoleWrite("64-Bit Program Files Directory: " & $g_sProgramFilesDir64 & @CRLF) joseLB and dogisay 2
joseLB Posted October 6, 2019 Author Posted October 6, 2019 factfinder/and Subz Thank you really very much! I will try undestand all that, I could´nt imagine that withou your help. I´m using x32, and can´t compile in x64, due to some dlls I use, for example, rs232 serial one. But if that is stable even under KLM as the example from Subz , it´s ok for me. This script must work in win7 and win 10. Tomorrow I will try in a win10 system, but I think it will work there, correct? Thanks again Jose
Subz Posted October 6, 2019 Posted October 6, 2019 Correct this should work on all Windows OS, I currently use it on XP, 7 and 10 Pro/Enterprise and also 2008, 2012, 2016 and 2019 Server. joseLB 1
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