Created
January 31, 2024 21:29
-
-
Save realslacker/fe055121912eff41dfedd15602edfa05 to your computer and use it in GitHub Desktop.
Java Seek and Destroy - Remove Oracle JRE 6-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
GOTO :RUN | |
:UNINSTALL | |
ECHO ------------------------------------------------------- | |
ECHO UNISTALL 32-Bit java matching "%~1" | |
ECHO ------------------------------------------------------- | |
SET FindCmd=REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f "%~1" | |
FOR /f " usebackq delims={} tokens=2" %%i IN (`%FindCmd%`) DO ( | |
ECHO Uninstall Key: {%%i} | |
START /WAIT msiexec.exe /x {%%i} /qn /norestart | |
SET MSIEXIT=!ERRORLEVEL! | |
ECHO Uninstall Exit: !MSIEXIT! | |
IF !MSIEXIT! NEQ 0 ( | |
IF !MSIEXIT! NEQ 3010 ( | |
EXIT /B !MSIEXIT! | |
) | |
) | |
) | |
ECHO ------------------------------------------------------- | |
ECHO UNISTALL 64-Bit java matching "%~1" | |
ECHO ------------------------------------------------------- | |
SET FindCmd=REG QUERY HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /s /f "%~1" | |
FOR /F " usebackq delims={} tokens=2" %%i IN (`%FindCmd%`) DO ( | |
ECHO Uninstall Key: {%%i} | |
START /WAIT msiexec.exe /x {%%i} /qn /norestart | |
SET MSIEXIT=!ERRORLEVEL! | |
ECHO Uninstall Exit: !MSIEXIT! | |
IF !MSIEXIT! NEQ 0 ( | |
IF !MSIEXIT! NEQ 3010 ( | |
EXIT /B !MSIEXIT! | |
) | |
) | |
) | |
EXIT /B 0 | |
:CLEANREG | |
ECHO ------------------------------------------------------- | |
ECHO CLEANING REGISTRY | |
ECHO ------------------------------------------------------- | |
REM Removing known problem registry keys. I use the below line to SET the variable of which reg.exe to use depending on OS architecture. | |
REM Additional registry removal strings can be added here. | |
IF EXIST "%SystemRoot%\SysWOW64\reg.exe" ( | |
SET Reg32Path=%SystemRoot%\SysWOW64\reg.exe | |
) ELSE ( | |
SET Reg32Path=%SystemRoot%\System32\reg.exe | |
) | |
REM %Reg32Path% DELETE HKLM\SOFTWARE\JavaSoft /va /f | |
%Reg32Path% DELETE "HKLM\SOFTWARE\JavaSoft\Auto Update" /va /f | |
%Reg32Path% DELETE "HKLM\SOFTWARE\JavaSoft\Java Update" /va /f | |
EXIT /B 0 | |
:CLEANFILES | |
ECHO ------------------------------------------------------- | |
ECHO CLEANING FILES | |
ECHO ------------------------------------------------------- | |
RD /s /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Java" | |
REM RD /s /q "%ProgramFiles%\Java" | |
REM RD /s /q "%ProgramFiles(x86)%\Java" | |
EXIT /B 0 | |
:RUN | |
CALL :UNINSTALL "Java* 6 Update " | |
IF %ERRORLEVEL% NEQ 0 GOTO :EXITERROR | |
CALL :UNINSTALL "Java* 7 Update " | |
IF %ERRORLEVEL% NEQ 0 GOTO :EXITERROR | |
CALL :UNINSTALL "Java* 8 Update " | |
IF %ERRORLEVEL% NEQ 0 GOTO :EXITERROR | |
CALL :CLEANREG | |
IF %ERRORLEVEL% NEQ 0 GOTO :EXITERROR | |
CALL :CLEANFILES | |
IF %ERRORLEVEL% NEQ 0 GOTO :EXITERROR | |
EXIT /B 0 | |
:EXITERROR | |
EXIT /B 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment