Skip to content
⌘ NSIS Forum Archive

Reading a 64bit registry key with 32bit NSIS installer

11 posts

voxio#

Reading a 64bit registry key with 32bit NSIS installer

Hi Guys,

I have a Windows Server 2008 machine (64bit) and I'm trying to grab a value from the registry with a 32bit NSIS installer binary but I get re-directed to Wow64node even with SetRegView 64 set.

I'm using the following code to check the JRE version and grab java_home:

${elseif} $arch == "64"
        ;check for 64bit JRE on 64bit
        SetRegView 64
        ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
        Messagebox MB_OK "1: $1"
        ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$1" "JavaHome"
        ;check for 32bit JRE on 64bit
        ${if} $2 == ""
            ReadRegStr $1 HKLM "SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment" "CurrentVersion"
            ReadRegStr $2 HKLM "SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\$1" "JavaHome"
        ${endif}
    ${endif} 
The MessageBox always prints $1 as nothing even though the registry key exists.

Any help would be appreciated.
Anders#
Where did $arch get set? AKA are you sure this is a 64 bit system?

And with anything like this, just fire up Process Monitor and check which key is accessed
voxio#
$arch gets picked up correctly.

Process monitor says it's trying to access:

RegOpenKey HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment NAME NOT FOUND Desired Access: Read

So its definitely forcing me over to the 64bit side.
Afrow UK#
Are you sure you have a 64-bit JavaSoft key (not in Wow6432Node)? I don't have one on any of my Windows x64 machines.

Stu
voxio#
Hi Afrow,

If you install 32bit JRE on a 64bit machine (which I believe is the default) the correct registry keys are placed in Wow6432Node. If you install 64bit JRE on a 64bit machine the registry keys are placed in the 64bit registry.
MrRichards#
Hi,
I'm sorry to bring this up again, but is there a way to delete Registry-Values from a 64 Bit Programm?

I tried
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "SunJavaUpdateSched" 
But when looking for what NSIS is trying to delete, I can see that NSIS tries to delete from

"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\SunJavaUpdateSched" 
Why is it doing so and is there a way to prevent this?
Anders#
Originally Posted by MrRichards View Post
Hi,
I'm sorry to bring this up again, but is there a way to delete Registry-Values from a 64 Bit Programm?

I tried
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "SunJavaUpdateSched" 
But when looking for what NSIS is trying to delete, I can see that NSIS tries to delete from

"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\SunJavaUpdateSched" 
Why is it doing so and is there a way to prevent this?
SetRegView
MrRichards#
Thank you!

I need to read Registry-Strings from Programs that are 64 Bit and from some, that are not (these are in the Wow6432Node). When I call 'SetRegView 64', can I call
DeleteRegValue HKLM "SOFTWARE\Wow6432Node\Something 
then or is the only way calling 'SetRegView 32' to get this string?
Also, what happens if I call SetRegView 64 on 32 Bit Systems? Does this affect the installer in any way?
MSG#
These things are trivially simple to test by yourself. Why don't you just try it, and see what happens?
sr164w#
Hii
I am trying to access 32bit registry from 63bit machine using SetRegView 32
though 32bit software installed in the registry it is showing tat its not installed.
MSG#
You'll need to give more details. For example, some code example of how you write (and then read!) the registry keys.