This content has been marked as final. Show 5 replies
1st question. Why uninstall?
You can just install the new version over the top (assuming you did a normal install previously)
The uninstall string is slightly different for each version look at the last 5 characters in the string it has the version number IE. 17009 or 17010 etc
So for 1.7.0.09
Hope that helps.
982176 wrote:Whats your second question then, huh? ;)
1st question. Why uninstall?
Uninstalling first is a safety strategy that has been applied to Windows environments since its inception. In the case of Java, upgrades are not guaranteed flawless depending on the environment it installs in, just take a stroll through the history of this particular sub-forum to see the proof. I must say that even though I know what I'm doing, I too tend to just uninstall all existing runtimes and JDKs and then reinstall the latest ones; I tend to have multiple installed being a developer (32 bits, 64 bits, runtime, JDK) and I'd like to have to prevent doing system restores because the stars are not aligned properly :/
All of our users are local admins and tend to install whatever. This leads to a messy environment and we don't always know which version of Java is installed. So, to address that, I created a small script that scours 'HKLM\software\microsoft\windows\currentversion\uninstall' for Java entries, reads the uninstall string then runs the reported uninstall string. The assumption here is that the uninstall string will be an MSI command. (All the machines & versions of Java used the same format.)
This is a Windows 7 Enterprise (32-bit) environment, but the script also works on 64-bit installations of Windows 7 Enterprise.
I've tested this with 7u11 and went as far back as 6u21. It should work with just about any version that uses MSI for uninstalling.
@echo off setlocal enabledelayedexpansion echo. & echo Checking for Obsolete Versions of Java... for /f "usebackq tokens=*" %%a in (`reg query HKLM\software\microsoft\windows\currentversion\uninstall`) do ( rem echo a is %%a for /f "usebackq tokens=2*" %%b in (`reg query "%%a" /v DisplayName 2^>nul ^| find /i "java"`) do ( rem echo b is %%b rem echo c is %%c for /f "usebackq tokens=3,4" %%d in (`reg query "%%a" /v UninstallString 2^>nul`) do ( echo. Removing %%c rem echo d is %%d rem echo e is %%e set uninstallcmd=%%e set uninstallcmd=!uninstallcmd:^/I=^/X! rem %%d %%e /qb- %%d !uninstallcmd! /qb- ) ) ) :end endlocal
Neither I nor the respective owners and/or maintainers of Oracle make representations about the suitability of this software for any purpose. This material is provided "as is", with absolutely no warranty of the attached items whatsoever, whether express, implied, or statutory, including, but not limited to, any warranty of merchantability or fitness for a particular purpose or any warranty that the contents of the item will be error-free. Any use is at your own risk. Blah blah blah.
Great Script! This worked like a charm. For some reason though the script throws an error that says something like "Command not found "Version"" but it still works. I just chose to ignore the error and use the script as-is.
Thanks for the work on this. this is by far the best way to uninstall java (or anything else!)