I am looking for a batch file snippet that somehow reads the Windows registry and detects which Java JRE's are on a Windows system and then asks the user which one they want to use and remembers the choice.
Here is what I have so far... needs some modifications. This script only finds the first JDK... it doesn't handle multiples.
::Get the home directory of the most recent JDK
start /w regedit /e reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\%JavaTemp%"
type reg1.txt find "JavaHome" > reg2.txt
if errorlevel 1 goto ERROR
for /f "tokens=2 delims==" %%x in (reg2.txt) do set JavaTemp=%%~x
if errorlevel 1 goto ERROR
echo Java home path (per registry) = %JavaTemp%
set JAVAHOME=%JavaTemp%