Skip to content

Unattended Install: Sun Java Runtime Environment 1.6 Update 1

For a more up-to-date version of this script, please see this page: Unattended Install: Unattended Install: Sun Java Runtime Environment 1.6 Update 3

This script uses the Java Runtime Environment (JRE) 6 Update 1 Windows Offline package downloadable from the Sun Java web site. You use this link for a direct download:

Sun Java Runtime Environment 1.6 Update 1 Windows Offline Installation

For full details on a silent installation see the Silent Installation documentation on the Sun web site. The first part of this script will install the JRE and set a number of options including disabling the updater and the Java icon displayed in the system tray:

@ECHO OFF
ECHO Sun J2SE Runtime Environment 6 Update 1..
START /WAIT jre-6u1-windows-i586-p-s.exe /s ADDLOCAL=jrecore IEXPLORER=1 MOZILLA=1 JAVAUPDATE=0 REBOOT=Suppress /L %SYSTEMROOT%\TEMP\JRE6setup.log
REM Find the lastest version of the install JVM from the default path
PUSHD "%ProgramFiles%\Java" & FOR /D %%d IN (*) DO SET JAVAVERSION=%%d & POPD
REM Remove the "jre" text from the variable
FOR /F "tokens=2 delims=e " %%i in ("%javaversion%") DO SET JAVAVERSION=%%i
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Plug-in\%JAVAVERSION%" /v HideSystemTrayIcon /t REG_DWORD /d 0×00000001 /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v EnableJavaUpdate /t REG_DWORD /d 0 /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v EnableAutoUpdateCheck /t REG_DWORD /d 0 /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v NotifyDownload /t REG_DWORD /d 0 /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v NotifyInstall /t REG_DWORD /d 0 /f
IF EXIST "%ALLUSERSPROFILE%\Desktop\Java Web Start.LNK" DEL "%ALLUSERSPROFILE%\Desktop\Java Web Start.LNK"
IF EXIST "%PUBLIC%\Desktop\Java Web Start.LNK" DEL "%PUBLIC%\Desktop\Java Web Start.LNK"
IF EXIST "%ALLUSERSPROFILE%\Start Menu\Programs\Java Web Start\Java Web Start.LNK" RD /Q /S "%ALLUSERSPROFILE%\Start Menu\Programs\Java Web Start"
IF EXIST "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Java Web Start\Java Web Start.LNK" RD /Q /S "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Java Web Start"

The second part of this script will add registry settings to fool some specific applications into seeing the version of the JRE they are expecting. This will help you with only installing a single version of the JRE:

REM Configure Java for known applicatons..
ECHO Configuring environment for Presentation Server 4.5..
REM Find the lastest version of the install JVM from the default path
PUSHD "%ProgramFiles%\Java" & FOR /D %%d IN (*) DO SET JAVAVERSION=%%d & POPD
REM Remove the "jre" text from the variable
FOR /F "tokens=2 delims=e " %%i in ("%javaversion%") DO SET JAVAVERSION=%%i
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.5.0_09" /v JavaHome /d "%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.5.0_09" /v MicroVersion /d "0" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.5.0_09" /v RuntimeLib /d "%ProgramFiles%\Java\jre%JAVAVERSION%\bin\client\jvm.dll" /t REG_SZ /fECHO Configuring environment for Presentation Server 4.0..
REM Find the lastest version of the install JVM from the default path
PUSHD "%ProgramFiles%\Java" & FOR /D %%d IN (*) DO SET JAVAVERSION=%%d & POPD
REM Remove the "jre" text from the variable
FOR /F "tokens=2 delims=e " %%i in ("%javaversion%") DO SET JAVAVERSION=%%i
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_06" /v JavaHome /d "%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_06" /v MicroVersion /d "2" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_06" /v RuntimeLib /d "%ProgramFiles%\Java\jre%JAVAVERSION%\bin\client\jvm.dll" /t REG_SZ /f
 
ECHO Configuring environment for IBM BladeCentre/RSA management..
REM Find the lastest version of the install JVM from the default path
PUSHD "%ProgramFiles%\Java" & FOR /D %%d IN (*) DO SET JAVAVERSION=%%d & POPD
REM Remove the "jre" text from the variable
FOR /F "tokens=2 delims=e " %%i in ("%javaversion%") DO SET JAVAVERSION=%%i
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_10" /v JavaHome /d "%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_10" /v MicroVersion /d "2" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_10" /v RuntimeLib /d "%ProgramFiles%\Java\jre%JAVAVERSION%\bin\client\jvm.dll" /t REG_SZ /f
 
ECHO Sun Array Manager..
REM Find the lastest version of the install JVM from the default path
PUSHD "%ProgramFiles%\Java" & FOR /D %%d IN (*) DO SET JAVAVERSION=%%d & POPD
REM Remove the "jre" text from the variable
FOR /F "tokens=2 delims=e " %%i in ("%javaversion%") DO SET JAVAVERSION=%%i
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_13" /v JavaHome /d "%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_13" /v MicroVersion /d "2" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_13" /v RuntimeLib /d "%ProgramFiles%\Java\jre%JAVAVERSION%\bin\client\jvm.dll" /t REG_SZ /f

If you are installing the JRE to 64 bit Windows, you will need to make a couple of adjustments to the script because the JRE is still a 32 bit application:

  • Change %ProgramFiles% to %ProgramFiles(x86)%
  • Ensure the 32bit version of REG.EXE is executed by adding this path to the REG command: %SYSTEMROOT%\SYSWOW64\