Jump to content

java install script

Recommended Posts

I just so happen to have recently finished up my java install script. I put a lot of time in to making this script flexible so it can be updated quickly when new versions come out so I am using http download and variables heavily.


You will need to extract the msi files, I've used Oracles normal folder names so you can just grab the whole folders, instructions here to do that https://www.java.com/en/download/help/msi_install.xml , and then put them in the path use in the script or adjust the script to where you want to put the files.


Also this script installs the 32bit and 64bit java versions, if this is undesired you will have to adjust a bit. All that needs to be changed to install a different version is the global variables. It also disables annoying update prompts. There are ticket lines included if you want to enable those after you are done testing.


Lastly, there are 4 scripts included all together because the original was getting way too large so I broke out some of the repetitive functions to separate scripts.

_Java JRE 7u60 Install.zip

Link to post
Share on other sites

Thanks rgreen,


There is a lot of good stuff in those scripts, but what I really need is one that downloads from the java website and not our labtech server. Is there a reason you decided to use the .msi instead of the .exe? I have scripts that install the .exe for flash player and reader from the websites with no problem. I don't understand why java is such a pain.

Link to post
Share on other sites

I also download reader and flash from adobe and install from .exe files. I looked at doing this with java first, but the java .exe is just a wrapper for the .msi, the silent commands must be ran against the .msi. I also looked at starting the .exe, copying the .msi and .dat files on the fly, and then killing the .exe but there is no way to do this silently and adds a lot of complication I didnt want to mess with at the time anyways.

Link to post
Share on other sites
  • 2 weeks later...
  • 3 weeks later...

I got tired of Java install scripts that didn't work, so I wrote my own. Specifically, I wrote 2: 1 for 32-bit installations, and 1 for 64-bit installations. Also, keep in mind, Oracle recommends 64-bit PCs should have both 32- and 64-bit versions of Java installed.


So, my aim was to create a script that has its own version control built in--I don't want to have to monkey with scripts whenever a new version of Java comes out. Luckily, Oracle packages new Java installs with the Version # built into the installer--this means I can use the install packages Version # field to check if the new version needs to be installed. Because of this, if I need to update the version of Java that I deploy, I just download the new install package from Oracle, and place it on my web-server. (More about distribution later)


Just to be safe, keep in mind that this works for me, but might not work for you. Use at your own risk...


Below is my 32-bit installer. (The 64-bit installer is identical, but uses the 64-bit binary installer)

1. Toggle FasTalk ON
3. LOG:  Remote URL: @REMOTE_URL@
4. LOG:  Checking for [COMPANY] Directory in local PC's %ltsvcdir% folder.
5. IF FILE Exists  %ltsvcdir%\[COMPANY]  THEN  Jump to line 8
6.    LOG:  No [COMPANY] folder found.  Creating.
7.    Create Folder: %ltsvcdir%\[COMPANY]
8. IF FILE Exists  %ltsvcdir%\Installer_Version.bat  THEN  Jump to line 11
9.    LOG:  Installer version batch file is not on PC.  Downloading.
10.    DOWNLOAD:  /Labtech/Transfer/Installer_Version.bat  saved to  %ltsvcdir%\Installer_Version.bat
11. LOG:  Retreiving UNC Path for files.
13. EXECUTE as Admin:  robocopy.exe @UNC_PATH@\Packages\JAVA %ltsvcdir%\[COMPANY]\JAVA *.* /M
14. LOG:  Robocopy Output: %executeresult%
15. SET:  @INSTALLER_PATH@ = %ltsvcdir%\[COMPANY]\JAVA\Java32.exe
18. LOG:  UNC Path is either not set, or not available.
19. IF FILE Exists  %ltsvcdir%\[COMPANY]\wget.exe  THEN  Jump to line 22
20.    LOG:  WGET is not on the local PC.  Downloading from @REMOTE_URL@/wget.exe.
21.    DOWNLOAD:  @REMOTE_URL@/wget.exe  saved to  %ltsvcdir%\[COMPANY]\wget.exe
22. EXECUTE:  %ltsvcdir%\[COMPANY]\wget.exe -r -nH --cut-dirs=4 --no-parent --reject="index.html*,web.config*" -e robots=off -P %ltsvcdir%\[COMPANY] "@REMOTE_URL@/Packages/JAVA/"
23. LOG:  %executeresult%
24. SET:  @INSTALLER_PATH@ = %ltsvcdir%\[COMPANY]\JAVA\Java32.exe
26.    LOG:  Unable to download installer to PC.  Exiting with error.
27.    Script Exit with Error
29. Resend Software
30. LOG:  Checking if this requested install is the same as the one currently installed.
31. SHELL:  %ltsvcdir%\Installer_Version.bat @INSTALLER_PATH@
32. SET:  @INSTALLER_VERSION@ = %shellresult%
33. SET:  @CURRENT_VERSION@ = SQLRESULT[sELECT `Version` FROM `software` WHERE `Name` REGEXP '^Java.+[^(64-bit)]' AND `ComputerID`='%computerid%']
34. LOG:  PC version: @CURRENT_VERSION@                Installer version: @INSTALLER_VERSION@
36.    LOG:  The new installer is attempting to install the same version we already have installed.  Exiting Script.
39. LOG:  Installing software from @INSTALLER_PATH@
40. EXECUTE:  @INSTALLER_PATH@ /s /L C:\Java32_Setup.log
42. Resend Software
43. Sleep 5 seconds
44. SET:  @NEW_VERSION@ = SQLRESULT[sELECT `Version` FROM `software` WHERE `Name` REGEXP '^Java.+[^(64-bit)]' AND `ComputerID`='%computerid%']
45. LOG:  PC version: @NEW_VERSION@                Installer version: @INSTALLER_VERSION@
46. IF  @INSTALLER_VERSION@  Contains  @NEW_VERSION@  THEN  Jump to line 51
47.    LOG:  The installation was NOT successful.  Exiting script with error.
48.    SHELL:  type C:\Java32_Setup.log
49.    LOG:  %shellresult%
51. LOG:  The software was successfully installed.  Exiting Script.
52. :END_SCRIPT - Label


(Now that I'm reading through this again, I see several points this could be streamlined and re-done...but it works!)


There is a Batch file required for this to run. It is called Installer_Version.bat:

setlocal enabledelayedexpansion

for /f "tokens=*" %%i in ('wmic datafile where Name^="%WMICPATH%" get Version /format:list ^| findstr "[A-Z]"') do set output=%%i
for /f "tokens=2 delims==" %%i in ("%VERSIONINFO%") do set output=%%i
echo %output%


echo No arguments were passed to script.  Exiting...





Now, a bit about Distribution of packages:

All of my customers have a physical file server on-premises. This creates a HUGE opportunity to save bandwidth! Here is the basic idea:

1. All install packages are kept on a single web-server, which is accessible from any Internet connection.

2. All on-premises file servers sync files (using wget.exe) from the web-server at pre-determined intervals, and share them via CIFS.

3. In LT, on the Location screen, I have an Extra-Data Field which specifies the UNC Path where these files are stored.

4. All computers attempt to download files from the on-premises file server first.

** If the computer cannot locate the necessary file on the file server (usually because the computer is not on-site), then it downloads the file manually.


I do all of this through LT. It isn't perfect, but it does fairly well.

Link to post
Share on other sites
  • 3 months later...
  • 5 months later...
  • 3 weeks later...

Where does your script fail at? I tried the script and it worked just fine. It only installed the 64-bit version of Java though. It is also installing 8u45 not 8u25. The only change I made to the script is I disabled the "Create new ticket" lines.

Link to post
Share on other sites
  • 1 month later...

Wanted this to work so.....

First I wanted to uninstall all older versions of java.

Used SHELL: wmic to do that

(see remove java script in attachment)

Then in wanted to install both 32 and 64 bit Java 8u45.

I used adminscottj's file and moded it with the correct BundleID's from the java site.

(see java v8u45 script in attachment)

It worked on my Win7Pro test bed.


Thanks for everyones help with this.


Link to post
Share on other sites
  • 1 month later...

Problem installing Java from the script.


I get this error in the script log when I run the script above. I only edited it to include the latest version of Java (8.51 7/17/15) The script is easy to edit so I just added the off-line Java installer with the latest version. Can anyone point me in the right direction?


%windir%\ltsvc\packages\java\jre-8u51-windows-i586.exe file was not found. Download may have failed please make sure agent can download the file. Exiting Script

Link to post
Share on other sites

Ok, so it must have been the Friday blues when I tried this last week because I tried it again today and it worked fine. I'll test again on another workstation.



So far so good, the only unfortunate part is I have to run a Uninstaller first, wait then run this script, a little time consuming but it gets the job done.

Link to post
Share on other sites
  • 3 months later...

Yes it is a great utility, however if I were to reset it and they tried logging into that account, we would be in trouble. Also, I don't think it is possible to use it on a remote computer? My issue still exists of trying to silently install it in the background without the administrative password.

Link to post
Share on other sites
  • 2 months later...

I'm having an issue with the latest Java update. I reconfigured the 8.45 script to include the new version of Java (114687-x86, 114689-x64) by just changing those download numbers and everything seems to work until it see that there is another version on the existing computer. Here is the error I get: "Java software version 8.0.450 was found to already be installed. Exiting Script."


I'm thinking it is in line 6 of the script:

6 >SELECT `Version` FROM software WHERE ComputerID = @computerid@ AND `Name` LIKE 'Java%' LIMIT 1

Java JRE v8.71.zip

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...