Jump to content

RegWrite HKLM64 with different results


Recommended Posts

Hi folks,

64 Bit XP Systems are a lot of fun. what would the world be like without it...

Whatever - I am trying to write a registry value to HKLM64\SOFTWARE\SOMEDIR\

It is a normal string key.

I have two different script EXEs.

One of them is writing to the correct registry path at HKEY_LOCAL_MACHINE\SOFTWARE\SOMEDIR\dealercode

The other one should write a reg key to HKEY_LOCAL_MACHINE\SOFTWARE\SOMEDIR\url

But the key ends up in HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\SOMEDIR\url

Does anybody had similar problems yet?

This code is working:

Global $gPosRegRoot = "HKLM64\SOFTWARE\SOMEDIR\"

...

    If StringRegExp($gDealerCode,'\A(\d\d\d\d\d)\z',0) Then
        If RegWrite($gPosRegRoot, "dealercode", "REG_SZ", $gDealerCode) Then
            _WriteLog("Successfully wrote value to registry. Dealer code: " & $gDealerCode)
        ElseIf @error <> 0 Then
            msgbox(262192, "Error", "Error writing values to the registry. Dealer code: " & $gDealerCode)
            _WriteLog("Error writing value to registry. Dealer code: " & $gDealerCode)
            Global $error = 1
        EndIf
    Else
        msgbox(262192, "Error", "The dealer code does not meet the defined format."  & @CRLF & "Please ensure the dealer code is correct and re-check it."  & @CRLF & @CRLF & "The code should be 5 digits long (e.g. 01234)")
        Global $error = 1
    EndIf
    If StringRegExp($gLocalMarket,'\A([:alpha:][:alpha:])-([:alpha:][:alpha:])\z',0) Then
        If RegWrite($gPosRegRoot, "localmarket", "REG_SZ", $gLocalMarket) Then
            _WriteLog("Successfully wrote value to registry. Local market: " & $gLocalMarket)
        ElseIf @error <> 0 Then
            msgbox(262192, "Error", "Error writing value to the registry. Local market: " & $gLocalMarket)
            _WriteLog("Error writing value to registry. Local market: " & $gLocalMarket)
            Global $error = 1
        EndIf
    Else
        msgbox(262192, "Error", "The local market does not meet the defined format.")
        Global $error = 1
    EndIf

This code is not working (respectively, pointing to the wrong reg path):

Global $REG_ROOT = "HKLM64\SOFTWARE\SOMEDIR\"

...
; Read the value "URL" from the registry key 
    $REGURL =  RegRead($REG_ROOT, "URL")
    If @error <> 0 Then
        _WriteLog("Maintenance, _DownloadFile, Error reading registry value from: " & $REG_ROOT & ", setting URL to default 'www.myurl.com/pos/" & $BrandName & "/maintenance/update' and writing Registry value.")
        $REGURL = "www.myurl.com/pos/" & $BrandName & "/maintenance/update"
        RegWrite($REG_ROOT, "URL", "REG_SZ", $REGURL)
        If @error <> 0 Then
            _WriteLog("Maintenance, _DownloadFile, Error writing registry value to: " & $REG_ROOT & "/" & $REGURL)
        EndIf
    EndIf
Edited by roka
Link to comment
Share on other sites

ok, I figured out that the script which writes in wow6432Node is executed by SYSTEM since it's a service which starts the executable.

The other script is executed by ADMINISTRATOR and works fine with HKLM64. Even if a user of POWER USERS is executing the script, it writes to the correct registry.

I'll check what's happening when I start the first script by Administrator instead of SYSTEM.... keep u posted.

cheers

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...