Friday, October 18, 2013

Java 7 update 45 Enterprise deployment

Java 7 update 45 Enterprise deployment

1. Download the latest version of Java from the Windows Offline download page from the following URL http://www.java.com/en/download/manual.jsp
2. From a Administrator command prompt launch the jre-7u45-windows-i586.exe and wait until the initial 'Welcome to Java' screen appears but do NOT press the 'Install' button.

3. At this stage Java will have expanded the installation files to C:\Users\Administrator\AppData\LocalLow\Sun\Java\jre1.7.0_45 > Copy this folder and contents to C:\temp\jre1.7.0_45
There will be two files: jre1.7.0_45.msi and data1.cab
(NOTE: it will be in the LocalLow directory of the user account used to run the command prompt, this example used a local admin account 'Administrator')

4. Use Orca to create an MST file which we can use to transform the MSI for enterprise deployment. Orca is part of the 'Microsoft Windows SDK' can be downloaded here http://www.microsoft.com/en-us/download/details.aspx?id=3138 (useful link here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370557(v=vs.85).aspx)

4.1 Right click the jre1.7.0_45.msi and select 'Edit with Orca'
4.2 Within Orca Click the 'Transform' dropdown and select 'New Transform'
4.3 At this stage you are not making changing to the original MSI but a Transform file (MST)

5. Select the 'Properties' table on the left and amend the property values as described below on the right
- AUTOUPDATECHECK = 0
- IEXPLORER = 1
- JAVAUPDATE = 0
- JU = 0
- RebootYesNo = No

6. Still within the properties table on the left, click any row on the right.
6.1 Click the Table drop down, and select 'Add Row', using the following Property's and values add the following 4 rows.

Property: REBOOT
Value: R
-------------
Property: SYSTRAY
Value:0
------------
Property: WEB_JAVA
Value: 1
-------------
Property: WEB_JAVA_SECURITY_LEVEL
Value: H
------------

7. Click the 'Transform' dropdown and select 'Generate Transform' and save as 'jre1.7.0_45.mst' in the same directory as the MSI.

8. The original MSI and the newly create MST file can be called with the following syntax
msiexec /i jre1.7.0_45.msi TRANSFORMS=jre1.7.0_45.mst /l*v C:\Windows\Contoso\Logs\Java_7_Update_45.log /qn /norestart

9. When Java is run to upgrade a previous version, the upgrade code detects previous versions and it will be removed prior to deployment.  This process fails when either the /qn switch is used and you reinstall the same version or when Java is currently being used in Internet Explorer.  Both senarios result in a successfull exit code however, the installation has failed and cannot be reinstalled silently, or Loud without a error pop up refering to a missing 'installer.dll.'
9.1 To address both these issues the following two scripts will be of assistance.  One if used at the begining will alway remove the current version before reinstalling.  The second will recover the system to avoid the 'Installer.dll' error.
10. The main feature of the script below to avoid this 'failed state' is the fact that current/previous version is uninstalled
strMSIUni = "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217045FF} /qn /norestart "
The script below will check to see if IEXPLROER.EXE is running and depending on the whether this is true or not display the SMSNotify.exe wrapper.  If it is not running SMSNotify will not be displayed and the MSI will use only silent switches.

'********************************************************************
'*
'* Author:       syswow64.co.uk
'*
'* Module Name:  sms-notify-Java.vbs
'*
'* Abstract:     Wrapper script for handling non zero exit codes on SMSNotify
'*
'* Exit codes:   0 - Install successful
'*               10 - Install successful (delayed)
'*               NB. All other codes are the MSIEXEC.EXE exit codes
'*
'* Changelog:   18/10/2013 - Java 7 update 45
'*              Check to see if a user is logged on first           
'*
'********************************************************************
On Error Resume Next
Dim oShell, objWMIService
strComputer = "."
'--check to see if IE is running and records it PID
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")
For Each objItem in colItems
    If InStr(objItem.CommandLine, "iexplore.exe") Then
       intProcessID = objItem.ProcessID
    End If
Next
Set colMonitoredProcesses = objWMIService.ExecNotificationQuery _
    ("Select * From __InstanceDeletionEvent Within 1 Where TargetInstance ISA 'Win32_Process'")
'--
Set oShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputerName = oShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
strCurrentDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
if intProcessID = "" then
 'Wscript.Echo "PId blank."
 RunInstall(True)
 'i = 1
 'wscript.quit
else
iReturn = oShell.Run(Chr(34) & strCurrentDir & "SMSNotify.exe" & Chr(34), 1, false)
  Do Until i = 1
   Set objLatestProcess = colMonitoredProcesses.NextEvent
   If objLatestProcess.TargetInstance.ProcessID = intProcessID Then
    Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'SMSNotify.exe'")
    For Each objProcess in colProcessList
    objProcess.TContosoinate()
    Next 
   i = 1
   End If
  Loop
'Wscript.echo "Loop ended"
RunInstall(false)
End If

Sub RunInstall(blnQuiet)
 strCMD = oShell.ExpandEnvironmentStrings("%COMSPEC%") & " /c "
 strMSI = "msiexec.exe /i " & Chr(34) & strCurrentDir & "jre1.7.0_45.msi" & Chr(34) & " "
 strMSIUni = "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217045FF} /qn /norestart "
 strTransform = "TRANSFORMS=" & Chr(34) & strCurrentDir & "jre1.7.0_45-ie-sc.Mst" & Chr(34) & " "
 strLogging =  "/lv* " & Chr(34) & "%WINDIR%\Contoso\Logs\jre1.7.0_45.log" & Chr(34) & " "
 strLoggingUni = "/lv* " & Chr(34) & "%WINDIR%\Contoso\Logs\jre1.7.0_40_Uninstall.log" & Chr(34) & " "
 strRestart = "/norestart "
 strCommand = strCMD & strMsi & strTransform & strLogging & strRestart
 'strCommandUni = strCMD & strMsiUni & strLoggingUni & strRestart
intMSIReturn = oShell.Run(strMSIUni, 0 , True)
 If blnQuiet = True Then
'wscript.echo "True"
  intMSIReturn = oShell.Run(strCommand & "/qn", 0, True)
 Else
  intMSIReturn = oShell.Run(strCommand & "/qn+", 0, True)
 End If
 WScript.Quit intMSIReturn
End Sub



<#'********************************************************************
#'*
?# Powershell script
'* Author: syswow64.co.uk
'* Module Name: Test-Path-installer.dll.ps1
'*
'* Abstract: error pop up refering to a missing 'installer.dll.'  installer.dll should be present in the same directory as the ps1 script.
'* SCCM command line: powershell.exe -ExecutionPolicy Bypass -file "./Test-Path-Installer.dll.ps1"
'*
'*
'* Changelog: 18/10/2013 - Test-Path-installer.dll.ps1
'* Check to see if a file and folder exist.  If they dont they will be created/copied.
'*
'********************************************************************#>

$source =  ".\installer.dll"
$destinationfolder = "C:\Program Files\Java\jre7\bin"
$destination = "C:\Program Files\Java\jre7\bin\installer.dll"
$TestPathfile = Test-Path $destination
$TestPathfolder = Test-Path $destinationfolder
IF (!$TestPathfolder) {New-Item $destinationfolder -Type Directory}
IF (!$TestPathfile) {Copy-Item $source $destination -Verbose}


10 comments:

  1. In your script you only check to see if IE is open... would you add additional checks for Firefox and Chrome? Or can Java install with those browsers open? I was under the assumptions that all browsers must be closed.

    ReplyDelete
    Replies
    1. This is a good question. Add the additional process executables to addition if statements.
      If InStr(objItem.CommandLine, "iexplore.exe") Then
      intProcessID = objItem.ProcessID
      End If
      If InStr(objItem.CommandLine, "firefox.exe") Then
      intProcessID = objItem.ProcessID
      End If

      '(Check the firefox.exe is the the correct process)

      Delete
  2. Hi,

    Nice work, thank you.

    Could you explain in more detail the sitchers REBOOT and SYSTRAY?.

    I know about SYSTRAY for not showing the Java logo when starting, but it seems deprecated by Oracle in Java 7 an earlier versions. How could I hide the logo in the newer versions?

    I can see all the switches but SYSTRAY and REBOOT in the registry after the installation in the hive HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\1.7.0_45\MSI.

    On the other hand, I think it would be a good option to set all those Java switches with Windows Group Policy Preferences.

    Thank you.

    ReplyDelete
    Replies
    1. I will update the article soon with the details of the switches i.e. REBOOT, SYSTRAY

      Delete
  3. Some really good info here! I’m getting ready to deploy 7U40 and have found it behaves very similar to what you are reporting with 7U45
    Is the installer.dll the root cause of the broken installs? I was contemplating making that DLL part of the detection method in SCCM this could help with the false exist code 0

    ReplyDelete
    Replies
    1. Yes, when the Java MSI runs it will check for the existance and content of installer.dll and without it a pop up error is produced before proceeding with either the uninstallation or reinstallation.

      Delete
  4. hi,
    I am new to vb script and sccm, where can I have the smsnotify.exe and when do you call the pst since the vb script for uninstall is commented out

    I appreciate the

    ReplyDelete
  5. Nice info, but I cannot find this SMSNotify either, but found some old references to it from 2004...? Is it available for download somewhere? Sorry if this is a stupid question.

    Anyway, thanks for the nice scripts.

    ReplyDelete
  6. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

    ReplyDelete