Solved

bat file to remove all old versions of Java

Posted on 2013-01-22
4
1,718 Views
Last Modified: 2013-02-02
Does anyone have a bat file that will remove all old versions of Java?  I need to automate the removal of all old versions of Java and install the latest 7u11.
0
Comment
Question by:dxwieland
  • 3
4 Comments
 
LVL 13

Expert Comment

by:IT_Crowd
ID: 38805898
0
 

Accepted Solution

by:
dxwieland earned 0 total points
ID: 38826943
the following BAT file ended up working for me:

@echo off & cls
Rem List all Installation subkeys from uninstall key.
echo Searching Registry for Java Installs
for /f %%I in ('reg query HKLM\SOFTWARE\microsoft\windows\currentversion\uninstall') do echo %%I | find "{" > nul && call :All-Installations %%I
echo Search Complete..
goto :EOF
:All-Installations
Rem Filter out all but the Sun Installations
for /f "tokens=2*" %%T in ('reg query %1 /v Publisher 2^> nul') do echo %%U | find "Oracle" > nul && call :Oracle-Installations %1
goto :EOF
:Oracle-Installations
Rem Filter out all but the Sun-Java Installations. Note the tilda + n, which drops all the subkeys from the path
for /f "tokens=2*" %%T in ('reg query %1 /v DisplayName 2^> nul') do echo . Uninstalling - %%U: | find "Java" && call :Oracle-Java-Installs %~n1
goto :EOF
:Oracle-Java-Installs
Rem Run Uninstaller for the installation
MsiExec.exe /x%1 /qb
echo . Uninstall Complete, Resuming Search..
goto :EOF
0
 

Author Comment

by:dxwieland
ID: 38826958
close
0
 

Author Closing Comment

by:dxwieland
ID: 38846375
this was a simple and thorough way to remove all versions of Oracle Java.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This article will shed light on the latest trends when it comes to your resume building needs. For far too long, the traditional CV format has monopolized the recruitment market.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question