Package - Java Runtime Environment (JRE)
JRE install/reinstall package
This will help you do unattended install of JRE. JRE is a little tricky as there are several major versions. There are 32bit and 64bit editions. There are regular updates. And there are plenty of security vulnerabilities that need patching regularly, especially the java plug-in for web browsers. Currently Oracle release JRE updates every quarter and this needs to become more frequent. As a result you need good version control for your packages and reliable install and upgrades. Sit down with a Java developer to agree on any JRE customisations (see post install actions).
Preinstall actions
A powershell script to query WMI for previous JRE updates and remove them ready for fresh install/reinstall. Look at the commented out lines and pick the JRE edition you’re interested in.
# Global variables and functions first
function install-msi([string]$MSIPath,[string]$LogPath,[string]$Properties)
{
$args = "/i `"$MSIPath`" /passive"
if ($LogPath -ne $null) { $args+=" /l+ `"$LogPath`"" }
if ($properties -ne $null) { $args+=" $properties"} $msiFile=split-path -leaf $MSIPath write-host “Installing $msifile” [diagnostics.process]::start(“msiexec”, $args).WaitForExit() } function uninstall-MSIByQuery([string]$WQLQuery) {
WQL query
write-host “Finding $WQLQuery” $apps=Get-WmiObject -Class Win32_Product -ComputerName . -Filter $WQLQuery if ($apps -ne $null) { foreach ($app in $apps) { $name=$app.name write-host “Removing $name” $app.uninstall() > $null } } }
Main routine
# Terminate any web browser processes to enable java plugin to be updated
write-host "Terminating web browsers for java plugin upgrade."
taskkill /f /im iexplore.exe /t
taskkill /f /im chrome.exe /t
taskkill /f /im firefox.exe /t
write-host “Terminating java processes.”
# Stop Java quick starter
try
{
get-serice -name JavaQuickStarterService | stop-service -force
}
catch
{
# Nothing to do
}
taskkill /im jqs.exe /f /t
Stop Any running Java Applications
taskkill /im java.exe /f /t taskkill /im javaw.exe /f /t taskkill /im javaws.exe /f /t
write-host "Removing old versions of JRE7 32bit"
#uninstall-MSIByQuery -WQLQuery "(Name LIKE 'Java 7 Update%') AND NOT (Name LIKE '%(64-bit)%')"
write-host “Removing old versions of JRE7 64bit” #uninstall-MSIByQuery -WQLQuery “(Name LIKE ‘Java 7 Update% (64-bit)’)”
write-host "Removing old versions of JRE6 32bit"
#uninstall-MSIByQuery -WQLQuery "(Name LIKE 'Java(TM) 6 Update%') AND NOT (Name LIKE '%(64-bit)%')"
write-host "Removing old versions of JRE6 64bit"
uninstall-MSIByQuery -WQLQuery "(Name LIKE 'Java(TM) 6 Update% (64-bit)')"
Sorry, blog software lost the indentation….
Install
- Download JRE SE from Oracle website. 32bit and 64bit versions
- Launch the EXE. It extracts MSI and cab files to: %appdata%\LocalLow\Sun\Java. Use these extracts for the 32bit and 64bit packages
- use the following MSI switches, in additional to the regular logging and /passive to turn off the pesky auto update tool
AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0 MODIFYREMOVE=remove SYSTRAY=0 REBOOT=REALLYSUPRESS
Post install actions
Set the following reg keys to supress the java updater [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy] "EnableJavaUpdate"=dword:00000000 "EnableAutoUpdateCheck"=dword:00000000 "NotifyDownload"=dword:00000000 "NotifyInstall"=dword:00000000
Copy your custom deployment.properties file to “C:\Windows\Sun\Java\Deployment\ if you need to supress warnings in web browsers. See JRE docs. deployment.security.level=MEDIUM deployment.security.revocation.check=NO_CHECK
Find more IT Infrastructure tips at blog.alexmags.com