Scripting Question

How to Remove all versions of Java

08/13/2015 8698 views
There are tons of older posts on this and nothing that is cut and dry. What is the best way to remove all versions of Java?
Answer Summary:
run on the system the following command: wmic product where "name like 'java%%'" call uninstall It can be automated.
1 Comment   [ + ] Show comment


  • You may check the powershell command to do the same

    $computers = Get-Content "C:\temp\computers.txt"

    ForEach-Object ( $computer in $computers ) {

    $java = Get-WmiObject -ComputerName $computer Win32_Product | WHERE { $_.name -like "J2SE Runtime Environment*" }



Answer Chosen by the Author

run this command:
wmic product where "name like 'java%%'" call uninstall

I do this as a KACE Script, following the installation of the most current Java version (or better the latest approved ;) )

Answered 08/13/2015 by: Nico_K
Red Belt

All Answers

You may try the powershell script that i found on other forum

$computers = Get-Content "C:\temp\computers.txt"ForEach-Object ( $computer in $computers ) {    $java = Get-WmiObject -ComputerName $computer Win32_Product | WHERE { $_.name -like "J2SE Runtime Environment*" }    $java.uninstall()    }
Answered 08/14/2015 by: Joe Prior
Orange Belt

The WMIC can work perfect indeed, but the win32_PRODUCT function is very buggy and slow.
And sometimes can trigger unwanted repairs, so just as a plan B:
You go over the registry path HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall and search for every hit on *JAVA* and then call the uninstall registry string (uninstallstring) in that key.
Because all software is registered there under there GUID code.

Here is a batch example

Answered 08/17/2015 by: dedenker
3rd Degree Black Belt


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ