myITforum and Windows IT Pro Forums

 SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finish

Author Message
JCortrig

  • Total Posts : 2
  • Scores: 0
  • Reward points : 430
  • Joined: 4/26/2017
  • Status: offline
SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finish Wednesday, April 26, 2017 3:28 PM (permalink)
0
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
 
SUMMARY
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.
 
UpdateJava.bat
----------------------------------
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 6.0.70.6
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
 
TIMEOUT 5
REM INSTALL JAVA 1.8.0_101
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 1.8.0.101 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.
 
 
 
#1
    llangley

    • Total Posts : 2
    • Scores: 0
    • Reward points : 100
    • Joined: 5/3/2017
    • Status: offline
    Re:SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finis Wednesday, May 03, 2017 8:56 AM (permalink)
    0
    Thank you for posting such a good, detailed article about how to manage Java with SCCM.  I wanted to add my two cents which might make your process just a little easier.  There are two steps in this process that you can consolidate into one which will make everything a lot easier.  By creating a custom query in the Monitoring workspace within SCCM, you can consolidate the steps on running a report AND finding the product ID.  I had to get creative and after a lot of trial and error, I have a clean query.  I set the Criteria at "Installed Software.ARPDisplay Name is like '%java%update%' AND Installed Software.ARPDisplay Name is not like '%java auto updater%'" ?(see attached file for the query language)?.  The results contain the following columns: NetBIOS name, arpdisplay name, product version, uninstall string, and install date.  The results will display multiple entries for machines (if you have both x86 and x64 versions installed like we do) but simple excel kung-fu will straighten that out easily.  Now you have a list of machines with ANY version of Java AND the uninstall string all in one place.
     
    Hope that helps make the process a little less painful :)
     
     
     
    ?????
    Attachment(s)JavaQuery.txt (0.51 KB) - downloaded 15 times
     
    #2
      JCortrig

      • Total Posts : 2
      • Scores: 0
      • Reward points : 430
      • Joined: 4/26/2017
      • Status: offline
      Re:SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finis Wednesday, May 03, 2017 10:09 AM (permalink)
      0
      Nice Query!  Wish I would have had this when I was building the package.  Could have saved some time.  Thanks for sharing!
       
      #3
        llangley

        • Total Posts : 2
        • Scores: 0
        • Reward points : 100
        • Joined: 5/3/2017
        • Status: offline
        Re:SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finis Wednesday, May 03, 2017 10:32 AM (permalink)
        0
        I have been working on scripting the majority of my applications so I can get better logging in the event that something goes wrong and I have to troubleshoot.  I am also doing this with my uninstalls as well.  I have attached a pretty neat script I wrote to automatically display the uninstall string and logging paramaters for the application defined in the $AppToMatch variable.  All you have to do is change the variable to say *'Java'* and the script will return the entire uninstall command.  You can then copy and paste it into your uninstall line in your application.  It will work on ANY piece of software that gets displayed in the Add/Remove programs view. 
        Attachment(s)UninstallApp.txt (1.47 KB) - downloaded 12 times
         
        #4
          gjones

          • Total Posts : 2770
          • Scores: 147
          • Reward points : 221210
          • Joined: 6/5/2001
          • Location: Ottawa, Ontario, Canada
          • Status: offline
          Re:SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finis Wednesday, May 03, 2017 11:47 AM (permalink)
          0
          if all you are looking for is all the uninstall strings then this query will do the trick.
           
          Attachment(s)Java.txt (0.26 KB) - downloaded 11 times
           
          #5
            gjones

            • Total Posts : 2770
            • Scores: 147
            • Reward points : 221210
            • Joined: 6/5/2001
            • Location: Ottawa, Ontario, Canada
            • Status: offline
            Re:SCCM Package to Unstall Old Versions of Java & Install one new Version - Start to Finis Thursday, May 04, 2017 5:05 PM (permalink)
            0
            I like your PoSH script however, I would not put the uninstall log within the C:\Windows\CCM\Temp\, instead use %temp% or c:\windows\temp
             
            #6
              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 2 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2017 ASPPlayground.NET Forum Version 3.9