Forum posts for regedit.exe

How to detect Java is installed via REGEDIT.exe from a batch file?

I am looking for a batch file snippet that somehow reads the Windows registry and detects which Java JDK is 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.

@echo off
SETLOCAL EnableDelayedExpansion
:: findJDK.bat
start /w regedit /e reg1.txt 'HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Development Kit'
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
echo Regedit: JAVA_HOME path : !JavaTemp!
)
if errorlevel 1 goto ERROR
echo.
set JAVA_HOME=%JavaTemp%
set JAVA_HOME=%JAVA_HOME:\=\%
echo JAVA_HOME was found to be %JAVA_HOME%
goto END
:ERROR
echo reg1.txt is: & type reg1.txt
echo reg2.txt is: & type reg2.txt
echo
:END
del reg2.txt
del reg1.txt
pause>nul

View complete forum thread with replies

Other posts related to regedit.exe

See Related Forum Messages: Follow the Links Below to View Complete Thread

.abc branch in regedit.exe
How does regedit.exe create empty binary values
Why I can't see 'wow6432node' when using process.start(“regedit.exe”)?
OpenSubKey() returns null for a registry key that I can see in regedit.exe
How to detect Java is installed via REGEDIT.exe from a batch file?
How can I run the regedit.exe from a Perl script on Windows 2008 Server?
Why does registryKey.GetValue still read the old value after I changed the rgistry with rege…

What is the carbon footprint of your coffee?

Is it low? Is it high? Can this things really kill the planet Earth? Maybe the answer will surprise you. Maybe not.