Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Java Cleanup x86
- ### This script will identify the latest version of Java and Rustle Jimmies with all prior versions.
- # Search registry for Java uninstall keys.
- $findJava = GCI -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall | `
- Get-Itemproperty | Select Displayname,UninstallString,DisplayVersion | `
- where {$_.displayname -match 'Java [0-9]+ Update'}
- # Find latest Java Version number.
- $latestJava = $findJava | Sort-Object -Property DisplayVersion | Select -ExpandProperty Displayversion -First 1
- # Filter out latest version and build list of versions to uninstall from registry.
- $uninstallJava = $findJava | where {$_.displayversion -ne $latestJava}
- # For each old version use uninstall string from registry and run as command to uninstall.
- if ($uninstallJava) {
- $uninstallJava | ForEach-Object {
- $uninstallString = $_ | select -ExpandProperty UninstallString
- & cmd /c $uninstallString /quiet
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement