Hi there
I’d like to only uninstall all 32bit Java 8 installation with the following command and leave 64bit installations of Java alone on Windows 10 computers.
Remove-MSIApplications -Name ‘Java 8 Update’ -FilterApplication (‘Is64BitApplication’, $false, ‘Exact’)
Sadly the command will always uninstall the 32bit AND 64bit Java installations.
Is this a bug and is there a workaround/alternative?
The following command works but I and leaves Java 8 64bit alone. But I’d like it to also uninstall versions before 221:
Remove-MSIApplications -Exact ‘Java 8 Update 221’
The string for the 64bit version is ‘Java 8 Update 221 (64-bit)’
So I’d like to look for ‘Java 8 Update’ followed by any build as long as the string doesn’t contain ‘(64-bit)’
Thanks for any help
bahnjee
September 13, 2019, 6:07pm
2
I use the following code to remove all versions of Java before installing the new 64-bit updates. Note the line continuation characters following each pipe, in the attempt to make the code more readable.
$uninstall32 = Get-ChildItem "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | `
ForEach-Object { Get-ItemProperty $_.PSPath } | `
Where-Object { $_ -match "Java " } | `
Select-Object -Property UninstallString
if ($uninstall32)
{
$uninstall32 = $uninstall32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall32 = $uninstall32.Trim()
Write-Log "Uninstalling older 32-bit version(s)..."
Start-Process "msiexec.exe" -ArgumentList "/x$uninstall32 /q" -Wait
}
$uninstall64 = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | `
ForEach-Object { Get-ItemProperty $_.PSPath } | `
Where-Object { $_ -match "Java " } | `
Select-Object -Property UninstallString
if ($uninstall64)
{
$uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall64 = $uninstall64.Trim()
Write-Log "Uninstalling older 64-bit version(s)..."
Start-Process "msiexec.exe" -ArgumentList "/x$uninstall64 /q" -Wait
}
64-bit Java should have (64-bit) name in Program and Features. To remove all Java 32-bit but leave Java 64-bit I used below command. For example: to remove all Java 8 Update xxx.
Remove-MSIApplications -Name ‘Java 8 Update’ -ExcludeFromUninstall (‘Is64BitApplication’, $true, ‘Exact’),(‘DisplayName’, ‘*(64 bit)’, ‘WildCard’)