Share This Post

Start to Finish: SCCM Package to Uninstall Old Versions of Java & Install one new Version

From our great web-based forums, member JCortrig has provided the following solution in the ConfigMgr 2012 area


After many hours of frustration and searching many different posts I wanted to post how we were able to uninstall all old versions of Java throughout our organization and install one version of Java that our business needs required. This post assumes you understand how to run reports and build packages in SCCM.

Our organization needed to uninstall all old versions of Java on all systems (a mix of Windows 7 32-bit, Windows 7 64-bit, and Windows 10 64-bit workstations), and then install version 8u101 of Java only, on all workstations and turn off AUTOUPDATE in the Java Installation. We needed it to run silent, passive, and not reboot the computer.  After much frustration and reading several technical posts and retrieving good information, with one post in particular where a tech shared his batch file -very helpful!  In the end these were the steps I used to generate one SCCM Package that did this all.  I tweaked the batch file to work in our situation. This worked for all our workstations with over 25 different versions Java dispersed throughout our organization. Once the package ran, we only had one version of Java on our workstations, and it was set to not automatically update – a requirement for a corporate software package that was critical to our business needs. Hope this helps someone else suffering from Java Frustration.

The steps used to make this happen.

  1. Extract the msi file from the Java exe file version that needs to be deployed
  2. Determine all old versions of Java in your organization
  3. Get the 32-digit Product code for every version of Java to be uninstalled
  4. Edit the attached batch file with the uninstall code for every version of Java to be removed
  5. Edit the attached batch file to point to the Java msi file extracted in step 1
  6. Copy the batch file & msi file to the share on your SCCM server for deploying the package
  7. Put the batch file in the command line for the program in your SCCM package

1. How to Extract the msi installer file for Java
You will need to extract the msi for the version of Java you want to deploy.  Since the java software is downloaded as an exe file, you cannot extract an msi out of it. To get the msi file, find the version of Java you need and run the executable (But Do Not Install it).  When you run the executable, the msi file is found under the path %userprofile%>appdata>locallow>Oracle>Java.

Copy the java%.msi file to a shared folder to be used in your SCCM Package (Step 6).  Once you’ve extracted the msi file, you can go ahead and cancel the Installation from the Java Welcome Screen.

2. The SCCM Report used to determine all Old versions of Java in your Organization
In order to uninstall old versions of Java from your workstations, you will need to first determine all current versions of Java in your organization.  I ran the following SCCM report which gave me every version of Java throughout our organization.  In the SCCM Console, under Monitoring>Reporting>Reports>Software-Files>Right click on and the report Computers with a specific file name and type in the value java.exe.  Then View Report.  This will return all versions of java.exe.  I exported this to an Excel Spreadsheet and then sort by version number.

3. Get the 32-digit Product code used to uninstall each version of Java, using SCCM Resource Explorer.
In order to push a silent uninstall of Java you will need to find the 32-digit Product code for each version of Java in your organization.  This is the most time consuming part of this process.  Taking the Excel Spreadsheet generated from Step 2, sorted by version number, find a workstation name for each version of Java listed.  Then in the SCCM Console under Assets and Compliance>Device Collections>All Systems, right click on a workstation name for a specific version of Java you wish to uninstall, and >Start Resource Explorer.

In Resource Explorer, under Hardware>Installed Applications, look for the version(s) of Java in the right window pain.  Under Product ID column you will find the 32 digit Product Code needed to uninstall the version of Java Listed.  I simply would right click on this line and choose copy.  I then pasted every version, with every 32-digit product Code into a Notepad file.  Do this step for each different workstation with a different version of Java that needs to be uninstalled.  You will need this information in the next step.

4. Edit the attached batch file with the Product code for every version of Java to be removed
Edit the contents of this batch file with any additional versions of Java not listed here by adding the uninstall codes collected from step 3.  The example listed here is simply called UpdateJava.bat.  You can give it any batch file name that makes sense to you.  The items under the dashed line contains the information in the batch file.  This example has six versions of Java listed.  Add to this, as necessary, any versions of Java collected from Step 3 that needs to be uninstalled.

REM *** This will uninstall ALL JAVA ***
taskkill /F /IM iexplorer.exe
taskkill /F /IM iexplore.exe
taskkill /F /IM firefox.exe
taskkill /F /IM chrome.exe
taskkill /F /IM javaw.exe
taskkill /F /IM jqs.exe
taskkill /F /IM jusched.exe

REM Uninstall Java 5.0.13
MsiExec.exe /X {3248F0A8-6813-11D6-A77B-00B0D0150130} /qn /norestart
REM Uninstall Java 6.0.31
MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216031FF} /qn /norestart
REM Uninstall Java
MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F03217067FF} /qn /norestart
REM Uninstall Java 7.0.670.1
MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F03217067FF} /qn /norestart
REM Uninstall Java 7.0.790.15
MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F06417079FF} /qn /norestart
REM Uninstall Java 8.0.1110.14
MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F32180111F0} /qn /norestart

msiexec.exe /i jre1.8.0_101.msi /quiet /passive /norestart JU=0 JAVAUPDATE=0 AUTOUPDATECHECK=0 RebootYesNo=No
exit /B %EXIT_CODE%


5. Edit the batch file to point to the java.msi file extracted in step 1
In the batch file from step 4, after a 5 second time out, the command to install Java is listed.  In our organization, we needed to install version and this is the information listed in this batch file.  This is the msi file that was extracted from Step One.  In this example, the command line parameters will also make changes to the installation so that once installed, JAVA will not update and will not look for Automatic Updates.  Also, the setting will run quiet, passive, and will not force a reboot.  Adjust these settings as appropriate for your organization. Save the batch file with a unique name appropriate for your organization.
6. Copy the batch file & msi file to the share on your SCCM server for deploying the package
Before using SCCM, If you wish to test this batch file before pushing this through SCCM copy the batch file and msi file to a folder on a workstation that has several old versions of Java installed.  Run the batch file from a DOS prompt logged in with an account that has Administrative Rights.  In addition, when you go to test his from the DOS prompt I found I needed to do shift+right click and say “Run as Administrator”, even though I was logged in as an Admin.  I tested this both on Windows 10, Windows 7 32 bit,  and a Windows 7 64 bit system, each having a variety of old versions of Java installed. Make a shared folder in your Package Source directory in SCCM and copy the msi file and the batch file to this folder.
7. Put the batch file in the command line for the program in your SCCM package
Now, you can simply create a new package and program pointing to this folder.  Make a package name and program name appropriate to your needs.  The batch file is the command line for your program.  Set the package to run whether or not a User is logged in using Administrative rights and allow Users to Interact with the program.  We ran the program hidden and no action required. After a few initial tests we then pushed this out to all of our workstations via SCCM with great success.


Looking for an awesome, no-nonsense technical conference for IT Pros, Developers, and DevOps? IT/Dev Connections kicks off in San Francisco in 2017!

IT/Dev Connections

Share This Post

Leave a Reply