Silently Remove all Java

By | February 3, 2017

In Microsoft Windows I frequently run into situations where customers have several outdated versions of Java, or not the “right” version required for a particular vendor.

Removing Java via Programs and Features is not the fastest and I sometimes found there are versions of Java that remain in the system even if they are not listed under Programs and Features.

The batch script below has worked very well for me and is useful if you want to deploy it in an automated fashion to several machines. It does need to be run as a local admin though.

RemoveAllJava.bat


@echo off
rem Oracle Java uninstall script
rem Author: VeneDude (candisa.org)

cls
echo.

echo Kill some programs that interfere with install...
taskkill /F /im iexplore.exe
taskkill /F /im java.exe
echo.

rem THE FOLLOWING SECTION MIGHT BE HELPFUL TO SOME
rem BUT YOU CAN PROBABLY REMOVE THIS SECTION SAFELY
echo Search for JAI and trigger silent uninstall (all versions)...
%SystemRoot%\IsUninst.exe -f"%ProgramFiles%\Java\jre6\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles%\Java\jre7\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles%\Java\jre1.6.0_03\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles%\Java\jre1.7.0_21\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles(x86)%\Java\jre6\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles(x86)%\Java\jre7\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles(x86)%\Java\jre1.6.0_03\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles(x86)%\Java\jre1.7.0_21\Uninstjai.isu" -a
%SystemRoot%\IsUninst.exe -f"%ProgramFiles%\Java\j2re1.4.1_02\Uninstjai.isu" -a
echo.

rem THE IMPORTANT PART IS BELOW
echo Search for Java and trigger silent uninstall (all versions)...
wmic product where "name like 'Java%% %%'" call uninstall /nointeractive
echo.

:DONE
echo.
echo.
echo DONE!
echo END: %date% %time%
echo.