Batch Files – Install or Uninstall Java

Pretty straight forward. Basically the first script will uninstall Java and the second will install it.

Java Uninstall

@echo off & cls
@echo ~~~ First lets get rid of some Java 5 ~~~
MsiExec.exe /X {3248F0A8-6813-11D6-A77B-00B0D0150080} /qn
MsiExec.exe /X {3248F0A8-6813-11D6-A77B-00B0D0150090} /qn
MsiExec.exe /X {3248F0A8-6813-11D6-A77B-00B0D0150000} /qn
MsiExec.exe /X {3248F0A8-6813-11D6-A77B-00B0D0150060} /qn MsiExec.exe /X {3248F0A8-6813-11D6-A77B-00B0D0150110} /qn
@echo ~~~ Now other versions of Java ~~~ MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217007FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83216023FF} /qn 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 "Sun" > nul && call :Sun-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 :Sun-Java-Installs %~n1
goto :EOF
Rem Run Uninstaller for the installation
MsiExec.exe /x%1 /qb
echo . Uninstall Complete, Resuming Search..
goto :EOF


Java Install

\\software\tools\Java\javasetup.exe /s /v" /qn IEXPLORER=1 MOZILLA=1"