Solved

bat file to remove all old versions of Java

Posted on 2013-01-22
4
1,700 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Firefox Display problems 5 47
WCAG (Web Content Accessibility Guidelines) levels 3 66
WordPress Header Issue 9 37
FireFox Add-on Plugins 2 19
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

912 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now