bat file to remove all old versions of Java

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.
Who is Participating?
dxwielandConnect With a Mentor Author Commented:
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
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
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
Rem Run Uninstaller for the installation
MsiExec.exe /x%1 /qb
echo . Uninstall Complete, Resuming Search..
goto :EOF
dxwielandAuthor Commented:
dxwielandAuthor Commented:
this was a simple and thorough way to remove all versions of Oracle Java.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.