This project is read-only.

Java x64 installation

Topics: Archive - Deployment Scripts
Jul 17, 2014 at 4:04 PM

I have created a package to install 32bit Java using the toolkit. This uninstalls previous versions of Java using the the Remove-msiapplication function to match the string 'Java 7 Update'. This all works fine however I've realised that the uninstall will also uninstall 64bit versions of Java which contain the same string in add remove programs.

Ideally I would like to have 2 separate packages, one for 32 bit and one for 64 bit, but obviously only want it to uninstall the correct version too. Is there a way to specify exactly what applications to uninstall without relying on just the string matching?

Jul 17, 2014 at 10:18 PM

Not using the Remove-MSIApplication function, but you could do something like this:
$javaInstalls = Get-InstalledApplication "Java 7 Update"
$javaInstallLocation = $javaInstalls | Select InstallLocation -Expand InstallLocation
$javaUninstallString = $javaInstalls | Select UninstallString -Expand UninstallString

Foreach ($javaInstall in $javaInstallLocation) {
    If ($javaInstallLocation -match "x86") {
        Execute-MSI -Action Uninstall -Path $javaUninstallString
You'll probably need to do the same if you have any Java 6 by looking for "Java(TM) 6 Update"

Also, check out the deployment script here:

Jul 18, 2014 at 9:48 AM
Edited Jul 18, 2014 at 10:25 AM

Great, thanks for the reply, it's set me on the right track. A couple of tweaks got it working.
#Remove old versions of 32 bit Java 7
if ((Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture -eq '64-bit') {            
 $architecture = "64-Bit" 
 $javaInstalls = Get-InstalledApplication "Java 7 Update" 

 Foreach ($javaInstall in $javaInstalls) {
   $javaInstallLocation = $javaInstall | Select InstallLocation -Expand InstallLocation
   $javaProductCode = $javaInstall | Select ProductCode -Expand ProductCode       
   If ($javaInstallLocation -match "x86") {               
     Execute-MSI -Action Uninstall -Path $javaProductCode         
    } else  {            
        $architecture = "32-Bit" 
        Remove-MSIApplications "Java 7 Update"