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`"" }</code>
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)
 write-host "Removing $name"
 $app.uninstall() &gt; $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
 get-serice -name JavaQuickStarterService | stop-service  -force
 # 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….


  1. Download JRE SE from Oracle website. 32bit and 64bit versions
  2. Launch the EXE. It extracts MSI and cab files to: %appdata%\LocalLow\Sun\Java. Use these extracts for the 32bit and 64bit packages
  3. use the following MSI switches, in additional to the regular logging and /passive to turn off the pesky auto update tool

Post install actions

Set the following reg keys to supress the java updater

Copy your custom file to “C:\Windows\Sun\Java\Deployment\ if you need to supress warnings in web browsers. See JRE docs.


Find more IT Infrastructure tips at


Leave a Reply