I had several versions of Java on my PC and I lamented the fact that I needed to use “Add/Remove Programs” to remove them. This script came in handy although my copy and paste of the code needed several fixups before it would work. The single and double quotes from the copy were funky according to DOS. So I have posted my cleaned up copy. The SyntaxHighlighter Plus plugin has solved this copy problem for me in the past. Good Luck!
Rem to run this file and log the output use: "uninstall java.bat">>java_remove.log
Rem @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 :NoneFound
: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 "Sun" > nul && call :Sun-Installations %1
goto :EOF
:Sun-Installations
Rem Filter out all but the Sun-Java Installations. Note the tilda + n, which drops all the subkeys from the path
echo %1
for /f "tokens=2*" %%T in ('reg query %1 /v DisplayName 2^> nul') do echo . Uninstalling - %%U: | find "Java" && call :Sun-Java-Installs %~n1
if errorlevel 1 (
echo Doing further conditional checking on variables.
for /f "tokens=2*" %%T in ('reg query %1 /v DisplayName 2^> nul') do echo . Uninstalling - %%U: | find "J2SE" && call :Sun-Java-Installs %~n1
)
goto :EOF
:Sun-Java-Installs
Rem Run Uninstaller for the installation
MsiExec.exe /x%1 /qb /quiet /passive /promptrestart
echo . Uninstall Complete, Resuming Search..
goto :EOF
:NoneFound
Rem No Java found to remove from this system
echo No Java found or all versions already removed from this system
goto :EOF
Related posts:
- BlogSecurity » Blog Archive » WordPress Scanner
- Obay Home » Blog Archive » Installing VMWare Player on Ubuntu
- JDK 1.5 and Java Web Start Problems
- BlogSecurity » Blog Archive » WPIDS v0.1.2 officially released
- wehuberconsultingllc.com » Blog Archive » jQuery 1.1.4 works but JQuery 1.2 breaks tablesorter for me
Related posts brought to you by Yet Another Related Posts Plugin.
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment