RD /s /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Java" %Reg32Path% DELETE "HKLM\SOFTWARE\JavaSoft\Java Update" /va /f Method 1: Uninstall Bat File Compiler 1.0 via. %Reg32Path% DELETE "HKLM\SOFTWARE\JavaSoft\Auto Update" /va /f Type wmic and press Enter you will see a prompt wmic:rootcli> 3.
REM %Reg32Path% DELETE HKLM\SOFTWARE\JavaSoft /va /f REM Additional registry removal strings can be added Defined ProgramFiles(x86) (SET "Reg32Path=%SystemRoot%\SysWOW64\reg.exe") Else (SET "Reg32Path=%SystemRoot%\System32\reg.exe")
I ran the above with admin creds on a local pc with ‘TeamViewer 6’ installed. So, I thought to use: wmic product where 'name like 'TeamViewer'' call uninstall. I use the below line to SET the variable of which reg.exe to use depending on OS architecture. As there are multiple ways to remove each version, I’d like a ‘catch all’ using a common variable and WMI commands. REM Removing known problem registry keys. To have WMIC successfully uninstall a product, you can set the script as a computer startup script. If using WMIC in a batch file you will want to use the local commands since each machine will be running the batch file individually. Rem List all Installation subkeys from uninstall key.Įcho Searching Registry for Java Installsįor /f %%I in ('reg query HKLM\SOFTWARE\microsoft\windows\currentversion\uninstall') do echo %%I | find " /qn /norestartĮCHO - WMIC can also be called from within a standard batch file. Since startup scripts run under the SYSTEM context, it will have the administrative rights that your users don’t have.
I found the following batch script on a forum post which looked promising: off & cls If using WMIC in a batch file you will want to use the local commands since each machine will be running the batch file individually. So, I can conveniently not have to worry about uninstalling the latest Java, because I can just do a search and uninstall all Sun Java programs. bat file it fails to find an instance of the product. However if I run the same command from within a. When running this directly from a command prompt it works fine. The neat coincidence is that Sun just got bought by Oracle and Oracle has now changed all the instances of "Sun" to "Oracle" in Java. wmic product where 'name like 'Infocouncil'' call uninstall. But old versions (such as 1.4) aren't removed by the installer, so I need to uninstall them.
msi file, and I've already tested that it can install the latest Java. I have a System Center Essentials server which can push out and silently run a. Everyone has all different versions of Java, many of them old and insecure, and some dating back as far as 1.4. I'm setting up a system to keep Java in our office up to date.