This script uses the latest Java Runtime Environment (JRE) 6 Windows Offline package downloadable from the Sun Java web site.
Version 1.6 Update 3 is currently available from the main Java web site - you use this link for a direct download for the 32-bit version: Sun Java Runtime Environment 1.6 Update 3 Windows Offline Installation. Version 1.6 Update 4 is also available, however I recommend sticking with Update 3 until Update 4 is released to java.com.
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 that is displayed in the system tray. In managed environments (desktops or Terminal Servers) these options are generally undesirable.
@ECHO OFF
ECHO Sun J2SE Runtime Environment 6 Update 3..
START /WAIT jre-6u3-windows-i586-p-s.exe /s ADDLOCAL=jrecore IEXPLORER=1 MOZILLA=1 JAVAUPDATE=0 AUTOUPDATECHECK=0 REBOOT=Suppress /L %SYSTEMROOT%\TEMP\JRE6setup.log
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"
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 1 /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
The second part of this script will add registry settings to fool applications expecting specific JRE versions into seeing those versions. Using this method you can install only the single JRE version whilst still maintaining compatability for older applications. To date I have not had an application fail under this method, but as always please test in your own environment first.
REM Configure Java for known applicatons..
ECHO Configuring environment for Presentation Server 4.5..
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.5.0_09" /v JavaHome /d "%ProgramFiles%\Java\jre%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 /f
ECHO Configuring environment for Presentation Server 4.0..
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_06" /v JavaHome /d "%ProgramFiles%\Java\jre%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_06" /v MicroVersion /d "0" /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..
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_10" /v JavaHome /d "%ProgramFiles%\Java\jre%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_10" /v MicroVersion /d "0" /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..
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_13" /v JavaHome /d "%ProgramFiles%\Java\jre%JAVAVERSION%" /t REG_SZ /f
REG ADD "HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_13" /v MicroVersion /d "0" /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 32-bit JRE to 64-bit Windows, you will need to make a couple of adjustments to the script:
- Change %ProgramFiles% to %ProgramFiles(x86)%
- Ensure the 32bit version of REG.EXE is executed by adding this path to the REG command: %SYSTEMROOT%\SYSWOW64\
The 64-bit version of the Sun JRE is available here: Java(TM) SE Runtime Environment 6 Update 3
Once the Sun JRE has been installed you will find a copy of the MSI file copied to the roaming portion of the profile of the account used to install the application: C:\Documents and Settings\%username%\Application Data\Sun\Java. If this account has a roaming profile, be sure to delete this ~14MB MSI file.







