How To Install Java 7 Update 11 Using a Script!

This is a script, with multiple tasks, that will install Java 7 Update 11 and remove previous versions

Pre Requisites

K1000
A test machine to push Java
Java 7 Update 11 Installer

 Download it here!

http://www.java.com/en/download/index.jsp


(Note:  On your test machine please have desktop or remote desktop access to it for troubleshooting.)

Configuring The Script

Configuring the script is pretty straight forward.  The most important part will come during the parameters.  Don't worry I have attached screenshots. :)

1.  From the home screen click on "Scripting".

 

2.  Click on "Add New Item".

3.  Choose Online KScript.

(Note:  Look to the right of this screen.  There are alot of helpful tips and explanations.)

4.  Change the Status to Production.

5.  Click the checkbox to enable the script.

(Note:  If this box is not checked the script will not run.)

6.  Choose a test computer before applying this script to a Smart Label.


7.  Choose a supported operating system.


Now comes the tough part.

8.  Add a new dependency.


(Note:  Browse to where the .exe file is located)

9.  Add a task.
    a.  Add a Verify task.
        i.  Verify a directory exists...
        ii.  Directory:  $(KACE_DEPENDENCY_DIR)
(Note:  This is where the Kbox download the dependencies too.)

  b.  Add an On Success task  

       i. Run a Batch File...
      ii. Script Name:Remove Old Versions of Java
      iii. Batch File:

{

@echo off

start /wait MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217011FF} /qn

start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150000} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150010} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150020} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150030} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150040} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150050} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150060} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150070} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150080} /qn
start /wait msiexec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150090} /qn

start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216010FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216011FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216012FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216013FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216014FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216015FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216016FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216017FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216018FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216019FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216020FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216021FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216022FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216023FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216024FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216025FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216026FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216027FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216028FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216029FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216030FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216031FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216032FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216033FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216035FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216036FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216037FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83216038FF} /qn

start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217001FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217002FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217003FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217004FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217005FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217006FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217007FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217008FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217009FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217010FF} /qn
start /wait MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F83217011FF} /qn

}


      iiii.Parameters:/qn
      iiiii.Save Changes

     

10. Add another Task
     a.  Add a Verify task.
        i.  Verify a directory exists...
        ii.  Directory:  $(KACE_DEPENDENCY_DIR)
(Note:  This is where the Kbox download the dependencies too.)

     b.  Add an On Success task         
       i.  Launch a Program.
      ii.  Directory:  $(KACE_DEPENDENCY_DIR)
     iii.  File:  jre-7u11-windows-i586.exe
    iiii.  Parameters:  /s /v /norestart AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0
   iiiii.  Check "Wait for completion" checkbox.

(Note:  These parameters worked on this program.  Different .EXE, .MSP's, and .MSI's require different parameters and you can find that information from the software manufacturer.  A link to a list of standard Installer Command Line Options can be found at the bottom of the blog.)

Your Policy or Job rules should look something like this!

Dependencies:

Task 1:

(Note:  This batch file removes most ofthe previous versions.  You might have to tailor the batch file to the needs of your environment.  Notice :Wait for completion is checked.")


Task 2:

 

(Note:  This task installs the exe silently turning off autoupdate checks.)


11.  Save the Script.

12.  Now click on the script you just created and run it by clicking on the "Run Now" button.

(Note:  For troubleshooting purposes enabling a custom pre-install message can be fun and let you know when the script is being pushed to the client.)

Did it work?

If so, then create a label that looks for machines in your environment that needs it.

Then add that label to the deployment section.

Congratulations!  You have created your script with a that installs Java 7 Update 11 and removes the previous versions.

Standard Installer Command Line Options

http://msdn.microsoft.com/en-us/library/windows/desktop/aa372024%28v=vs.85%29.aspx

Special Thanks goes out to my customer Mark D.

Comments

  • will this article be modified for update 13 or will it be an entirely new one ?
    • I will create an entire new one. It will have most of this content but with different screen shots an updated batch file and the correct switches for update 13.
      • Is the updated article up? I cannot seem to find it..
      • Hi c_brock,

        I'm messing with a script named remove all older version of java. i'm following your steps as described in Task 1 but i'm still not able to remove Java 8 Update 60 (x64). This is wat i'm doing . Can you help please. I need to remove java from 500 computers. Please :)

        {

        @echo off

        Start wait / MsiExec.exe /X {26A24AE4-039D-4CA4-87B4-2F86418060F0} /qn

        }
    • Hi,

      I'm looking for script to install Java 8 Update 66. I also need to remove the olver version of Java on the computers. Can u help me?

      Tnx, Kenan
  • Is it possible to get this to run when a user isn't logged in?
    • Yes! Look at scheduling. Just check the option to Allow Run While Logged Off :)
  • Did this on 7u13 and it seemed to work ok? what would be the difference?
    • I am working on that now, using the same exact script he walked us through, but instead of the 7u11 file, I am attaching the 7u13. Once I get that to work, I am going to work on editting the batch file to remove 7u11 versions as well.
    • The switches are the different. The installer wants everything after /s /v to be in quotes.
      • With regular distribution, this is how I have the jre-7u13-x64 installing silently, no UI and no reboot.

        "jre-7u13-windows-x64.exe" /s /v "/norestart AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0 IEXPLORER=1"

        also selecting Don't Prepend msiexec.exe
  • Hi Jng343! I am having trouble with the switches. They have changed them and I don't know how to input them the way the installer wants. That is the only hangup. As for the batch file....It is already uninstalling Java 7 update 11
    • c_brock, I editted the script to install 7u13 x64 file instead of the 7u11i586 as you had it in your script. It looks like the 7u13 did not install, and the script is also hanging up on the uninstall of previous version. I checked the logs and it is giving me this error like it isn't finding some directory. I also don't know why it is showing the directory has having two \\ in the path.

      Running as: SYSTEM
      Directory DOES exist: C:\ProgramData\Dell\KACE\\kbots_cache\packages\kbots\92
      Error creating process: C:\ProgramData\Dell\KACE\\kbots_cache\packages\kbots\92\kace2983.bat /qn: (0) The operation completed successfully.
      Error Code: 0
      Status Code: 1
      Running as: SYSTEM
      Directory DOES exist: C:\ProgramData\Dell\KACE\\kbots_cache\packages\kbots\92
      Error creating process: $(KACE_DIRECTORY_DIR)\jre-7u13-windows-x64.exe /s /v /norestart AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0: (2) The system cannot find the file specified.
      Error Code: 2
      Status Code: 0
      • you are not using the right installer file you need the offline installer file. Also your switches need work. I am thinking about running the first batch file and adding a wait 60 seconds then run a second batch file the launches the installer with the right switches /s /v "/norestart AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0"
  • how about for uninstaller step:

    powershell -command "${ $javas = gwmi win32_product | ? {$_.name -match 'Java'}; foreach($java in $javas){$java.uninstall() | out-null}}"
    • I am not so versed on powershell. Let us know your results. :)
  • Seems like the conversation is over on this one, but I was hoping to have a question answered on this. I'm using a more current version on my k1000, and under the "on success", I cannot add run a batch file. Is there another place that I need to go?
Please log in to comment