/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


How to Remove all versions of Java

08/13/2015 7094 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

Comments

  • 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*" }
    $java.uninstall()

    }

    Thanks
    Joe

Answer Chosen by the Author

4
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

1
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

1
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

0