0% found this document useful (0 votes)
50 views1 page

Remove Java

This PowerShell script uninstalls unwanted versions of Java and cleans up leftover files and registry entries. It stops any running Java processes, then uninstalls Java versions not on an approved list using MSIEXEC. Finally it removes registry entries under HKEY_CLASSES_ROOT and HKEY_LOCAL_MACHINE related to JavaSoft.

Uploaded by

Juntos PodCast
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views1 page

Remove Java

This PowerShell script uninstalls unwanted versions of Java and cleans up leftover files and registry entries. It stops any running Java processes, then uninstalls Java versions not on an approved list using MSIEXEC. Finally it removes registry entries under HKEY_CLASSES_ROOT and HKEY_LOCAL_MACHINE related to JavaSoft.

Uploaded by

Juntos PodCast
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

$RegUninstallPaths = @(

'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
)

$VersionsToKeep = @('Java 8 Update 261')

Get-CimInstance -ClassName 'Win32_Process' | Where-Object {$_.ExecutablePath -like


'*Program Files\Java*'} |
Select-Object @{n='Name';e={$_.Name.Split('.')[0]}} | Stop-Process -Force

Get-process -Name *iexplore* | Stop-Process -Force -ErrorAction SilentlyContinue

$UninstallSearchFilter = {($_.GetValue('DisplayName') -like '*Java*') -and


(($_.GetValue('Publisher') -eq 'Oracle Corporation')) -and ($VersionsToKeep -
notcontains $_.GetValue('DisplayName'))}

# Uninstall unwanted Java versions and clean up program files

foreach ($Path in $RegUninstallPaths) {


if (Test-Path $Path) {
Get-ChildItem $Path | Where-Object $UninstallSearchFilter |
foreach {

Start-Process 'C:\Windows\System32\msiexec.exe' "/X$($_.PSChildName) /qn" -


Wait

}
}
}

New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null


$ClassesRootPath = "HKCR:\Installer\Products"
Get-ChildItem $ClassesRootPath |
Where-Object { ($_.GetValue('ProductName') -like '*Java*')} | Foreach {
Remove-Item $_.PsPath -Force -Recurse
}

$JavaSoftPath = 'HKLM:\SOFTWARE\JavaSoft'
if (Test-Path $JavaSoftPath) {
Remove-Item $JavaSoftPath -Force -Recurse
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy