Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS: Unable to get JRE version from registry in Windows 7 64 bit

Tags:

registry

nsis

I'm using NSIS script to generate the windows installer for my Java project. In this installer, I want to check whether the computer has the right JRE version before proceeding.

This is my code snippet for getting the JRE version:-

ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"

# display $1 value for testing purpose
MessageBox MB_OK "Version: $1"

This code works fine in Windows XP, but I can't get it to work in Windows 7 64 bit... the version number is always blank. I check the registry, and I'm pretty sure the path is correct and "CurrentVersion" has a value.

Can anyone tell me what I do wrong here?

Thanks much!

like image 742
limc Avatar asked Dec 22 '22 20:12

limc


2 Answers

In NSIS, you can set the registry "mode" with SetRegView

like image 104
Anders Avatar answered May 09 '23 05:05

Anders


Is the installer 32 bit and the runtime 64 bit or vice versa? In that case you might get redirected to different registry nodes (inside HKLM/Software or HKLM/Software/Wow6432Node).

like image 24
Mario Avatar answered May 09 '23 05:05

Mario