Java Silent Install

Java Silent Install for SCCM The Right Way

Thanks to Jesse Walter, I now have an easy way to do a Java silent install and update Java with SCCM. I tested this today at a customer and it worked very nicely. Whenever a new version of Java is released they can now quickly update their SCCM package without any hassle.

Java Silent Install – Step-by-step

  1. Download the Offline 32 and 64-bit verions of Java (http://www.java.com/en/download/manual.jsp)
  2. Run the executable but don’t click through the prompts
    javainstall1
  3. In your packageshare, create a folder named Java with subfolder Java7UpdateXX_86 and Java7UpdateXX_64 (Where XX is the update version number).
  4. Browse to %userprofile%\AppData\LocalLow\Sun\java and copy the directory named jre1.7.0_xx (or directories if you prepare for both 32 and 64-bit). The directory contains a .msi and a .cab file. Copy the content of these folder into the folder at your packageshare with the same names.
  5. Create the Install.cmd and java_Uninstall.vbs and put the in your Java directory
    javainstall3

Java silent script – Install.cmd

@echo off

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 Call the uninstall script
cscript %~dp0Java_Uninstall.vbs

REM Install JRE x86
msiexec.exe /i %~dp0\Java7Update21_x86\jre1.7.0_45.msi /passive /norestart /l*v c:\windows\temp\Java7x86.log

REM Installing JRE x64
if exist %ProgramFiles(x86)%
msiexec.exe /i %~dp0\Java7Update21_x64\jre1.7.0_45.msi /passive /norestart /l*v c:\windows\temp\Java7x64.log

REM Disable automatic updates
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f
reg add "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Update\Policy" /v EnableJavaUpdate /t REG_DWORD /d 0 /f

REM Return the exit code to SCCM
exit /B %EXIT_CODE%

Java silent uninstall script – java_uninstall.vbs

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment Standard Edition %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'J2SE Runtime Environment %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java 2 Runtime Environment, SE *
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment, SE %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 6 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'")
For Each objSoftware in colJava6dot
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 7 Update *
Set colJava7dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 7 Update %'")
For Each objSoftware in colJava7dot
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 7 *
Set colJava7 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) %'")
For Each objSoftware in colJava7
objSoftware.Uninstall()
Next

Source: Jesse Walter (blogpost)

Anders Rødland

Anders Rødland started his IT career in 2006. My main focus is MS Configuration Manager and client management, and I currently hold active 15 Microsoft certifications. Certified on Windows Server, Windows Client, SQL, Exchange and System Center Configuration Manager. Anders Rødland also holds an ITIL Foundation certification. This is my private blog and do not represent my employer. I use this to share information that I find useful. Sharing is caring.