Remote and silent uninstall of all versions of java, with one command.

Just to preface, My user’s do not have the ability to install any software on their PC’s, therefore they cannot update each individual software package, such as JAVA Runtime, Adobe Flashplayer, Adobe Reader, etc…  these are about standard to have installed on each computer that accesses the internet, or receive emails.  Like usual, these are security vulnerabilities if they are not kept up-to-date.

Also, it should be noted that I despise when software does not ship with a standard MSI.  There is absolutely no way that I will go to every computer to install things like Adobe Reader, which is updated every quarter, and Adobe refuses to simply post an MSI for each update of Reader, and instead ships a patch for each release, so the SysAdmin has to build their own MSI, from Major release, to patch 1, to patch 2, to patch3, etc… Furthermore,  Java, is only available as an EXE, which extracts an MSI to the current user’s APPDATA folder.  from there, one is supposed to use ORCA to build a custom MSI using the options desired.  It is so annoying, if i want to use Group Policy to manage these updates.  Granted the Java EXE has silent install options, it DOES NOT uninstall the previous versions, and each one takes up to 100MB of disk space.

<end rant>

I needed a way to uninstall all versions of Java, remotely, and silently, so i can “secure” my end user’s PCs with latest releases.   This is when I came across some awesomeness using wildcards with the wmic command, as running with Domain Admin credentials.

The following will list all installed versions of Java on a local computer:

wmic product where “name like ‘Java%'” get name

The following will uninstall all versions of java on a local computer:

wmic product where “name like ‘Java%'” call uninstall

The following will uninstall all versions of java on a remote computer:

wmic /node:[computername] product where “name like ‘Java%'” call uninstall

therefore… if you have a list of computers stored in a text file… you can uninstall anything you want across a domain in one command:

for /f %n in (all-domain-pcs.txt) do wmic /node:%n product where “name like ‘Java%'” call uninstall


This is not  fast at all, but effective.  It definitely beats working on each pc one at a time, uninstalling each java update, one at a time.

The power of this tool is awesome, especially when planning for upgrades, when you want to uninstall every office installation

Disclaimer:  Use this at your own risk.  i will not be held responsible if you manage to uninstall everything from your domain computers.



Did you like this? Share it:
This entry was posted in Tips and tricks. Bookmark the permalink.

5 Responses to Remote and silent uninstall of all versions of java, with one command.

  1. Mike says:

    The final command gives an query error when trying to access domain computers.

    Works flawlessly on the local machine.

  2. Rob says:

    Thanks, it’s time for Java to go away!

    I think your blog tool broke your code by “prettifying” your quote characters. Also had errors until I replaced them with keyboard standard. This worked:
    wmic product where "name like 'Java%'" call uninstall
    …and this didn’t:wmic product where “name like ‘Java%’” call uninstall

  3. NetApex says:

    Side note, when you are trying to do domain computers, you might be required to surround the computer name in quotes. When I have to uninstall things on my network I have to do

    /node:”some-computer” product where “name like ‘software-to-remove%'” call uninstall
    (yes when prompted)

    Like the original author said, it isn’t the fastest, but it is nice when you don’t want to face the person for fear of a thousand other request, or when you should have already handled the problem a while ago and forgot about them.

  4. Jerry says:

    I have found that the word “NODE” must be capitalized in order for it to work and also if your computer name has a hyphen you must enclose the name in quotes.

  5. T Payne says:

    I put this one together that will start the process to the entire list at once in different command prompts. I usually do around 30 computers. More than that and the command prompts slow down. I have all my text files on the C: drive. Some computers hangs up for some reason. You have to be patient while the uninstall process starts.

    Echo off
    set /p UserInput= What computer.txt file?
    for /F %%i in (C:\%UserInput%.txt) do (
    start cmd /k wmic /Failfast:on /node:”%%i” product where “name like ‘java%%'” call uninstall /nointeractive

Leave a Reply

Your email address will not be published. Required fields are marked *