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
)
This Blog is for all people working or related to the MSI and App-V. There are lots of issues we face in everyday work regarding the technology. The sole purpose of my blog is to help others with whatever I learn. All you people out there, please help by commenting, voting, propagating and sharing my blog with your friends and colleagues but with due credit and acknowledgement to the material posted here with my name and blog url as I still do hold the copyright of the posts here.
Tuesday, February 03, 2015
Subscribe to:
Post Comments (Atom)
4 comments:
Hi Piyush,
I'm trying to test this batch file, which I also found over at http://en.wiki.schrotti12.eu/index.php/Remove_all_old_Java_versions but whenever I try to run it (saved to a .bat) I keep getting an Error: Too many command-line parameters. Any ideas?
Did you try running it with Admin Privileges?
Make sure the quotes are correct as well. In `%mycmd%` it is actually ` and not '
I'm too saved the above script to a bat file, run it with Admin Privileges but received an error message 'The system cannot find the path specified.'
Can you check if there are no undesired enter added in the lines. Also you need to check if the Add/Remove program has java in the name. Also check my previous comment in which you have to take care of quotes.
Hope it helps.
Post a Comment