I want to make my job a little easier, I tried creating a batch file to get the JRE path. I'm only getting the javaw.exe path. So for example we are using Team Center 10. It has this tem_init and it grabs the folder JRE7 (example version) but people update to the latest version and uninstall. I'm looking to make a batch file that automatically grabs JRE installed.
@echo off
setlocal enableextensions disabledelayedexpansion
rem Where to find java information in registry
set "javaKey=HKLM\SOFTWARE\JavaSoft\Java Runtime Environment"
rem Get java home for current java version
set "javaDir="
for /f "tokens=2,*" %%d in ('reg query "%javaKey%\%javaVersion%" /v "JavaHome" 2^>nul') do set "javaDir=%%e"
if not defined javaDir (
echo Java directory not found
) else (
set TC_JRE_HOME : %javaDir%
)
:end
endlocal
I wanna get a path like this C:\Program Files\Java\jre7
You could try this, (it assumes that the latest version will be the last returned result):
Edit
That seems to
Set
a variable unnecessarily, this doesn't:I've added the
Pause
commands just to allow for reading anyEcho
es.