JRE installation wrapper that verifies Java is not in-use at the time of installation
@ECHO OFF
SET JRE_RUNNING=
SET PROBLEM=
SET INST_FILE=%~n1
SET LOG_DIR=%windir%\system32\LogFiles
SET CMD_OPTS= /s REBOOT=ReallySuppress /L*v "%LOG_DIR%\%INST_FILE%_inst.log"
ECHO.
ECHO Check for installer requirements...
ECHO.
IF NOT EXIST "%~dp0%INST_FILE%.exe" (
ECHO NOT_FOUND %~dp0%INST_FILE%.exe
SET INST_FILE=
SET PROBLEM=1
) ELSE (
ECHO FOUND %~dp0%INST_FILE%.exe
)
IF NOT EXIST "%LOG_DIR%" (
ECHO NOT_FOUND %LOG_DIR%
SET LOG_DIR=
SET PROBLEM=1
) ELSE (
ECHO FOUND %LOG_DIR%
)
REM If running, exit installation or unexpected results will be encountered.
REM These executables were discoverd by running dir /b on the Java installation directory
REM This may need to be updated if these have changed.
FOR %%i IN (jabswitch.exe,java-rmi.exe,java.exe,javacpl.exe,javaw.exe,javaws.exe,jp2launcher.exe,jqs.exe,keytool.exe,kinit.exe,klist.exe,ktab.exe,orbd.exe,pack200.exe,policytool.exe,rmid.exe,rmiregistry.exe,servertool.exe,ssvagent.exe,tnameserv.exe,unpack200.exe) DO (
TASKLIST /FI "IMAGENAME eq %%i" | FIND /I /N "%%i">NUL
IF NOT ERRORLEVEL 1 (
ECHO RUNNING %%i
SET JRE_RUNNING=1
SET PROBLEM=1
) ELSE (
ECHO NOT_RUNNING %%i
)
)
ECHO.
IF DEFINED PROBLEM (
ECHO.
ECHO Problems were encountered. Please correct and try again.
ECHO.
IF DEFINED JRE_RUNNING ECHO In-use JRE instances detected.
IF NOT DEFINED INST_FILE ECHO Installer not found.
IF NOT DEFINED LOG_DIR ECHO Log output directory not found.
SET PROBLEM=
EXIT /B -1
)
ECHO.
ECHO Installing...
ECHO.
"%~1" %CMD_OPTS%