I have both 64-bit and 32-bit java installed on my system at locations C:\Program Files\Java\jre1.8.0_191
and C:\Program Files (x86)\Java\jre1.8.0_191
respectively.
I have the following code which fetches me the install location of a software on a system.
MsgBox fn_getInstallLocation("java")
function fn_getInstallLocation(strApplication)
Dim strKey, objReg, subkey, arrKeys, strRequiredPath
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strRequiredPath = ""
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" '<----THIS KEY IS IMPORTANT
set objReg = getObject("winmgmts://./root/default:StdRegProv")
objReg.enumKey HKLM, strKey, arrKeys
for each subkey in arrKeys
objReg.getStringValue HKLM, strKey&subkey, "InstallLocation", strInstallLocation
if InStr(1,strInstallLocation,strApplication,1)>0 Then
strRequiredPath = strInstallLocation
Exit for
End if
next
fn_getInstallLocation = strRequiredPath
End Function
My Observations:
- On keeping the strKey value to
SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
and running the above script using 64-bit wscript, I get the expected output asC:\Program Files\Java\jre1.8.0_191
. On changing the strKey value to
SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
and running the script using 64-bit wscript, I get the expected output asC:\Program Files (x86)\Java\jre1.8.0_191
On keeping the strKey value to
SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
ORSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
and running the above script using 32-bit wscript, I get the output asC:\Program Files (x86)\Java\jre1.8.0_191
(32-bit Java). Is there a way to get the install location of 64-bit java when this script is executed using 32-bit mode?
I am NOT playing around with different permutations and combinations. I am asking this because when I executed this script on a different machine, it did not give me proper results. The specifications of that machine are as follows:
OS: Windows 7 x64
Java: 64 bit(Not 32 bit) - In Registry Editor, it is present in the key - SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
The script ran in 32 bit mode(cannot switch to 64-bit on that machine because I am running this script on a tool - TestComplete which runs in 32-bit mode on all machines. If I do decide to run Test complete in 64-bit mode, there will be architecture mismatch issues with ODBC drivers.)
Because the script ran using the 32-bit wscript, It could not return me the installation path of 64-bit JAVA. So, Is there any way I can make this solution to run in 32-bit mode and fetch the install location of 64-bit Softwares?