1

Thanks for looking into my query.

I have a batch script to install java and I am using the below commands to capture JAVA_HOME and JRE_HOME paths. But, I see an error in reg query. Could you please help me with it.

Commands I am using:

set KeyName1=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
set Cmd=reg query "%KeyName1%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| findstr "JavaHome"') do set JRE_HOME=%%i

for /f "tokens=2*" %%a in ('reg.exe query "HKLM\Software\JavaSoft\Java Development Kit" /v "Path" ^| find /i "Path"') do echo JAVA_HOME=%%a

Error: ERROR: The system was unable to find the specified registry key or value.

Thanks.

Ras
  • 543
  • 1
  • 9
  • 25
  • Your registry query seems odd, surely you know the name of the registry value you're looking for. Also you're specifying the second token and the remainder which would in your cases be attributed to variables `%%i` & `%%j` and `%%a` & `%%b`. In each of those examples the data attributed to each of `%%i` and `%%a` will probably be `REG_SZ`, you would therefore be better advised using `%%j` and `%%b`. – Compo Aug 29 '17 at 00:49
  • What about using the batch script to get directory containing `java.exe` as posted [here](https://stackoverflow.com/a/44542924/3074564)? – Mofi Aug 29 '17 at 05:27

0 Answers0