Addy-Hussain Posted March 21, 2018 Posted March 21, 2018 Good afternoon, I was wondering whether if someone can help me with a script or a batch file that will remove all previous versions of Java completely, as we have over 500 Windows 7x64 Workstations. Once all previous versions of Java uninstalled, I am then going to deploy the latest version of Java using Group Policy. Can someone please help. Many Thanks
LeMarchand Posted March 21, 2018 Posted March 21, 2018 I probably got this from someone on here (or off the net), but this worked for me. @ECHO OFF If EXIST "C:\JavaRemove.txt" goto :END cls TITLE Uninstalling Java 5-8 and Java fx. . . wmic product where "name like 'Java 7%%'" call uninstall /nointeractive wmic product where "name like 'JavaFX%%'" call uninstall /nointeractive wmic product where "name like 'Java(TM) 7%%'" call uninstall /nointeractive wmic product where "name like 'Java(tm) 6%%'" call uninstall /nointeractive wmic product where "name like 'J2SE Runtime Environment%%'" call uninstall /nointeractive wmic product where "name = 'java 8 update 0'" call uninstall /nointeractive wmic product where "name = 'java 8 update 05'" call uninstall /nointeractive wmic product where "name = 'java 8 update 20'" call uninstall /nointeractive wmic product where "name = 'java 8 update 25'" call uninstall /nointeractive wmic product where "name = 'java 8 update 31'" call uninstall /nointeractive echo Removed >> "C:\JavaRemove.txt" goto END :END exit You'll have to add subsequent 8.* versions in. Hopefully you won't have any Java 4 or earlier. 1
Tones Posted March 21, 2018 Posted March 21, 2018 I'm a fan of the way Vocatus does it, here's a link to the script on github. It'll remove all versions and you can throw in a reinstall too if you add the location and set it to do that but I'd seperate it. Source pack can be found on Reddit. It's aimed at users of PDQ Deploy but works the same with however you want to run it
Katy Posted March 21, 2018 Posted March 21, 2018 (edited) I probably got this from someone on here (or off the net), but this worked for me. @ECHO OFF If EXIST "C:\JavaRemove.txt" goto :END cls TITLE Uninstalling Java 5-8 and Java fx. . . wmic product where "name like 'Java 7%%'" call uninstall /nointeractive wmic product where "name like 'JavaFX%%'" call uninstall /nointeractive wmic product where "name like 'Java(TM) 7%%'" call uninstall /nointeractive wmic product where "name like 'Java(tm) 6%%'" call uninstall /nointeractive wmic product where "name like 'J2SE Runtime Environment%%'" call uninstall /nointeractive wmic product where "name = 'java 8 update 0'" call uninstall /nointeractive wmic product where "name = 'java 8 update 05'" call uninstall /nointeractive wmic product where "name = 'java 8 update 20'" call uninstall /nointeractive wmic product where "name = 'java 8 update 25'" call uninstall /nointeractive wmic product where "name = 'java 8 update 31'" call uninstall /nointeractive echo Removed >> "C:\JavaRemove.txt" goto END :END exit You'll have to add subsequent 8.* versions in. Hopefully you won't have any Java 4 or earlier. Oooh clever, so I could do "java 8%%" in the above to remove ALL version 8 java. I had been doing it this way: REM 32 bit start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F83218045F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F83218091F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F32180101F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F32180111F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F32180121F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F32180131F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F32180144F0} /qn /norestart REM 64 bit start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F86418045F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F86418091F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F64180101F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F64180111F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F64180121F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F64180131F0} /qn /norestart start /wait msiexec.exe /x {26A24AE4-039D-4CA4-87B4-2F64180144F0} /qn /norestart which removed 8u45/91/101/111/121/131/144 (which are the versions I have installed as I don't update as fast as they spew out new updates) (That went in a start up script and only ran the uninstall sections if an old version was present, followed up by the installer for the new version) Edited March 21, 2018 by Katy This editor hates me pasting anything in :(
LeMarchand Posted March 21, 2018 Posted March 21, 2018 Oooh clever, so I could do "java 8%%" in the above to remove ALL version 8 java. Good point! The OP was going for a "nuke then install" approach, so that would be a smarter option. NB @Addy-Hussain usual test on an isolated machine warnings apply (for the script I posted at least - I wouldn't want to suggest that anyone else's needed testing!).
Carm01 Posted April 17, 2018 Posted April 17, 2018 I have a piece of code I wrote that does not use WMIC, as I found it is slow and you do not need to add any lines as it will handle any java 8 version as is. If anyone is interested in the AutoIT script; you will have to compile it ?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now