Jump to content

RegWrite & RegRead at "HKEY_LOCAL_MACHINE"


Recommended Posts


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)

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)

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.




Edited by joseLB
Link to comment
Share on other sites

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:
To access 64-Bit Hive - HKEY_LOCAL_MACHINE use:

Script compiled as 64-bit on a 64-bit Operating System:

To access 32-Bit Hive - HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node use:
To 64-Bit Hive - HKEY_LOCAL_MACHINE use:

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)


Link to comment
Share on other sites

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


Link to comment
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

  • Create New...