Tuesday, February 03, 2015

How to uninstall any version of Java

I wanted to uninstall Java from all the machines and install the latest one. There were sometimes multiple versions of Java which had to be removed. Some machines had both 32 bit and 64 bit Java versions. Here is the easiest batch script to uninstall any version of Java on the machine.
There were scripts available but they did not delete 64 bit versions of Java and some very old versions of Java. Hence I modified those scripts to meet my need.

set mycmd=reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f *java* for /f " usebackq delims={} tokens=2" %%i IN (`%mycmd%`) do ( msiexec /uninstall {%%i} /passive )
set mycmd=reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /s /f *java* for /f " usebackq delims={} tokens=2" %%i IN (`%mycmd%`) do ( msiexec /uninstall {%%i} /passive )