Solved How to find java runtime in dos on Windows 7

Wyndham

New member
Local time
10:57 PM
Messages
3
I have been unsuccessful in finding the right DOS commands to achieve this and would appreciate some help.

This is an extract from my registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6]
"JavaHome"="G:\\Program Files (x86)\\Java\\jre6"

Not sure why it is showing the double backslash...

I've tried various commands (in BATch files), such as the following, without success:

- - - -
@echo off
set KeyName=SOFTWARE\JavaSoft\Java Runtime Environment\1.6
REM set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
set Cmd=reg query "%KeyName%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j

set JAVA_HOME
pause
- - - -

Any help will be appreciated.

I know this can be set manually, but this is not what is needed.
 

My Computer

OS
Windows 7 RC
You have missed one detail:
Code:
@echo off 
set KeyName=[font=arial black][color=red]HKLM[/color][/font]\SOFTWARE\JavaSoft\Java Runtime Environment\1.6 
REM set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment 
set Cmd=reg query "%KeyName%" /s 
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j 
set JAVA_HOME 
pause
 

My Computer

Computer type
PC/Desktop
OS
Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
Other Info
"The scale icon at the top right of a post or tutorial is how you can give rep to the member."
Thank you for responding. I should have mentioned that your suggestion was one of the variations I had tried - sorry.

Here is a screen print showing the result of two different tests.

screenshot287.jpg


Thanks again for trying to help :)
 

My Computer

OS
Windows 7 RC
Neutron16's change worked for me. Should you be using HKLM64? I only have a 32bit VM to test in right now.

reg.JPG

Code:
cd\
set KeyName=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.6
set Cmd=reg query "%KeyName%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j
set JAVA_HOME
pause
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Employer provided Dell Latitude
OS
W7 Pro SP1 64bit
CPU
i7
Memory
8GB
Graphics Card(s)
Intel HD Graphics
Hard Drives
crappy SSD
Antivirus
Employer mandated Symantec Endpoint Protection
Browser
Pale Moon 64bit, IE11 64bit & Chrome 64bit
Excellent, thank you.

The successful search string is: HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment\1.6
 

My Computer

OS
Windows 7 RC
Great :-)
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Employer provided Dell Latitude
OS
W7 Pro SP1 64bit
CPU
i7
Memory
8GB
Graphics Card(s)
Intel HD Graphics
Hard Drives
crappy SSD
Antivirus
Employer mandated Symantec Endpoint Protection
Browser
Pale Moon 64bit, IE11 64bit & Chrome 64bit
Back
Top