User Tools

Site Tools


userspace:java-ng

This is an old revision of the document!


Java-NG

Feel free to contact me :)

Tested with opsi 4.0.3.1
requiredWinstVersion >= 4.10.8.3
Tested with Windows 7/8 Enterprise x64/x32
Tested with Java 6u24 - 7u51
By Kevin Weis 2014-01-17

Download: installable opsi package
First read: Important to know

Tree:
|-- UnlimitedJCEPolicy
|   |-- local_policy.jar
|   `-- US_export_policy.jar
|-- autoit3.exe
|-- check_uninstall.ins
|-- delsub.ins
|-- java.png
|-- javaFullSize.png
|-- setup.ins
`-- uninstall.ins
What is does, and what not

It Does:

  1. Uninstall all versions of Java from 1.6.0.10 until 1.7.0.51
  2. Handle x64 and x32 install and uninstall (Always install a x32 version of Java)
  3. Add the JCE Patch to every Java installation; see: JCE Documentation

It Does Not:

  1. Uninstall Java versions older then 1.6.0.10, because in update 10 was a new installer dropped which uses an other schema of GUID´s at the Windows Registry.
TODO
  1. Use the check_msi-exitcode script from “Der-Matze”: check_msi-exitcode
  2. May add support for removing older versions until 1.5.0.0
  3. Automate get the last entry of “$version7$” (“setup.ins”, “uninstall.ins” line: 52)
  4. Add support for installing and uninstalling Java JDK 7/8
  5. Add Java 8 (future use)
Important to know

This Package expect the installation files NOT at the ScriptPath! They should, for example, be located at:

%ScriptDrive%\Setup_data\java\msi\jre1.7.0_51\jre1.7.0_51.msi
%ScriptDrive%\Setup_data\java\msi\jre1.7.0_51_x64\jre1.7.0_51.msi

If it fails to find the resources, check your Samba Configuration and move the Setup_data directory or edit the winst script “setup.ins” and “uninstall.ins” at line 74, 60 and 61.
Note: The variables “exe32” and “exe64” are not in use at the moment.

check_uninstall.ins

check_uninstall.ins
for $x$ in $version6$ do sub_uninstall_6
for $x$ in $version7$ do sub_uninstall_7
 
[sub_uninstall_6]
Message "Suche Java 6.0.$x$ x32"
if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
	if ("$x$" > "24")
		Set $msi_suffix$ = "FF"
	else
		Set $msi_suffix$ = "F0"
	endif
 
	Set $DisplayName$ = GetRegistryStringValue ("[" + $Path$ + "{26A24AE4-039D-4CA4-87B4-2F832160" + "$x$" + $msi_suffix$ + "}] DisplayName")
	if not ($DisplayName$ = "")
		Message "Deinstalliere " + $DisplayName$ + "..."
		Set $MSI$ = "{26A24AE4-039D-4CA4-87B4-2F832160" + "$x$" + $msi_suffix$ + "}"
		sub "%scriptpath%\delsub.ins" 
	endif
endif
 
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
	if ("$x$" > "23")
		Set $msi_suffix$ = "FF"
	else
		Set $msi_suffix$ = "F0"
	endif
 
	Set $DisplayName$ = GetRegistryStringValue32 ("[" + $Path_64$ + "{26A24AE4-039D-4CA4-87B4-2F832160" + "$x$" + $msi_suffix$ + "}] DisplayName")
	if not ($DisplayName$ = "")
		Message "Deinstalliere " + $DisplayName$ + "..."
		Set $MSI$ = "{26A24AE4-039D-4CA4-87B4-2F832160" + "$x$" + $msi_suffix$ + "}"
		sub "%scriptpath%\delsub.ins" 
	endif
 
	if ("$x$" > "24")
		Set $msi_suffix$ = "FF"
	else
		Set $msi_suffix$ = "F0"
	endif
 
	Message "Suche Java 6.0.$x$ x64"
	Set $DisplayName$ = GetRegistryStringValue64 ("[" + $Path$ + "{26A24AE4-039D-4CA4-87B4-2F864160" + "$x$" + $msi_suffix$ + "}] DisplayName")
	if not ($DisplayName$ = "")
		Message "Deinstalliere " + $DisplayName$ + "..."
		set $MSI$ = "{26A24AE4-039D-4CA4-87B4-2F864160" + "$x$" + $msi_suffix$ + "}"
		sub "%scriptpath%\delsub.ins" 
	endif
endif
 
 
 
 
[sub_uninstall_7]
if ("$x$" > "23")
	Set $msi_suffix$ = "FF"
else
	Set $msi_suffix$ = "F0"
endif
 
Message "Suche Java 7.0.$x$ x32"
if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
	Set $DisplayName$ = GetRegistryStringValue ("[" + $Path$ + "{26A24AE4-039D-4CA4-87B4-2F832170" + "$x$" + $msi_suffix$ + "}] DisplayName")
	if not ($DisplayName$ = "")
		Message "Deinstalliere " + $DisplayName$ + "..."
		Set $MSI$ = "{26A24AE4-039D-4CA4-87B4-2F832170" + "$x$" + $msi_suffix$ + "}"
		sub "%scriptpath%\delsub.ins" 
	endif
endif
 
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
	Set $DisplayName$ = GetRegistryStringValue32 ("[" + $Path_64$ + "{26A24AE4-039D-4CA4-87B4-2F832170" + "$x$" + $msi_suffix$ + "}] DisplayName")
	if not ($DisplayName$ = "")
		Message "Deinstalliere " + $DisplayName$ + "..."
		Set $MSI$ = "{26A24AE4-039D-4CA4-87B4-2F832170" + "$x$" + $msi_suffix$ + "}"
		sub "%scriptpath%\delsub.ins" 
	endif
 
	Message "Suche Java 7.0.$x$ x64"
	Set $DisplayName$ = GetRegistryStringValue64 ("[" + $Path$ + "{26A24AE4-039D-4CA4-87B4-2F864170" + "$x$" + $msi_suffix$ + "}] DisplayName")
	if not ($DisplayName$ = "")
		Message "Deinstalliere " + $DisplayName$ + "..."
		set $MSI$ = "{26A24AE4-039D-4CA4-87B4-2F864170" + "$x$" + $msi_suffix$ + "}"
		sub "%scriptpath%\delsub.ins" 
	endif
endif
 
<code>
 
=== delsub.ins ===
<code winst delsub.ins>
Message "Deinstalliere " + $DisplayName$
set $UninstallCommand$ = 'msiexec.exe /X ' + $MSI$ + ' /qb! REBOOT=ReallySuppress /lie "c:\tmp\' + $DisplayName$ + '_uninstall.log"'
killtask "firefox.exe"
killtask "jqs.exe"
killtask "java.exe"
killtask "javaw.exe"
Winbatch_Uninstall
set $ExitCode$ = getLastExitCode
if $ExitCode$ = "1618"
	sleepSeconds 10
	Winbatch_Uninstall 
	set $ExitCode$ = getLastExitCode
	if $ExitCode$ = "1618"
		sleepSeconds 20
		Winbatch_Uninstall 
		set $ExitCode$ = getLastExitCode
		if $ExitCode$ = "1618"
			sleepSeconds 30
			Winbatch_Uninstall
			set $ExitCode$ = getLastExitCode
			if $ExitCode$ = "1618"
				sleepSeconds 40
				Winbatch_Uninstall 
				set $ExitCode$ = getLastExitCode
				if $ExitCode$ = "1618"
					sleepSeconds 50
					Winbatch_Uninstall 
				endif
			endif
		endif
	endif
endif
Sub_check_exitcode
if CompareDotSeparatedNumbers("%WinstVersion%","4.11.2") >= "0"
	includelog "c:\tmp\"+$DisplayName$+"_uninstall.log" "20"
endif
Message "Deinstallation von " + $ProductId$ + " abgeschlossen"
 
[Winbatch_Uninstall]
$UninstallCommand$
 
[Sub_check_exitcode]
comment "Test für die Installation erfolgt über Exit-Code"
Set $ExitCode$ = getLastExitCode
; Informationen zu Exit-Codes zu sehen
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
	comment "Sieht gut aus: Setup-Programm gibt Exitcode Null"
else
	comment "Setup Programm gibt einen unterschiedlichen Exitcode Null: " + $ExitCode$
	if ($ExitCode$ = "1605")
		comment "ERROR_UNKNOWN_PRODUCT	1605	Diese Aktion ist nur für Produkte gültig, die zurzeit installiert sind."
		comment "Deinstallieren eines nicht installierten Produkt fehlgeschlagen - Kein Problem"
	else
		if ($ExitCode$ = "1641")
			comment "sieht gut aus: Setup-Programm gibt exitcode 1641"
			comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	Der Installer hat einen Neustart eingeleitet. Diese Meldung weist auf einen Erfolg."
		else
			if ($ExitCode$ = "3010")
				comment "sieht gut aus: Setup-Programm gibt exitcode 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	Ein Neustart ist erforderlich, um die Installation abzuschließen. Diese Meldung weist auf einen Erfolg."
			else
				logError "Fatal: Setup-Programm gibt eine unbekannte Exitcode Null aus: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif

setup.ins

setup.ins
[Initial]
SetLogLevel=4
ExitOnError=true
ScriptErrorMessages=off
TraceMode=off
StayOnTop=false
 
[Aktionen]
requiredWinstVersion >= "4.10.8.3"
Message "Vorbereiten..."
DefVar $LogDir$
DefVar $msiPath$
DefVar $Reg_Path$
DefVar $Reg_Path_64$
DefVar $msi32$
DefVar $msi64$
DefVar $exe32$
DefVar $exe64$
DefVar $MSI$
DefVar $ExitCode$
DefVar $INST_MsVersion$
DefVar $INST_SystemType$
DefVar $INST_architecture$
DefVar $ProductId$
DefVar $UninstallCommand$
DefVar $DisplayVersion$
DefVar $DisplayName$
DefVar $DisplayVersionx32$
DefVar $DisplayVersionx64$
DefVar $MinimumSpace$
DefVar $msi_suffix$
DefVar $Path$
DefVar $Path_64$
DefVar $update_Version$
DefStringList $version6$
DefStringList $version7$
 
Set $ProductId$			= "Java"
; -------------------------------------------------------------------------------------------------------------------------------------------------------
; - Please edit the following values																	-
; -------------------------------------------------------------------------------------------------------------------------------------------------------
; Look up for new update versions of Java 6.
; https://en.wikipedia.org/wiki/Java_version_history#Java_6_updates
set $version6$				= createStringList ('10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '43', '45', '51', '65', '71')
 
; Add the new update version number to the stringlist, also add all version numbers you have skipped.
; https://en.wikipedia.org/wiki/Java_version_history#Java_7_updates
set $version7$				= createStringList ('00', '01', '02', '03', '04', '05', '06', '07', '09', '10', '11', '13', '15', '17', '21', '25', '40', '45', '51')
 
; increment the first takeString argument, by how much numbers you added to "$version7$". 
; this is used to get the last index of "$version7$"
Set $update_Version$		= takeString ( 18, $version7$ )
 
 
; -------------------------------------------------------------------------------------------------------------------------------------------------------
; - DO NOT EDIT ANY VALUES BELOW! Unless you want to edit the functionality of this.							-
; -------------------------------------------------------------------------------------------------------------------------------------------------------
Set $DisplayVersion$		= "7.0." + $update_Version$
Set $MinimumSpace$		= "123 MB"
Set $msi32$				= "msi\jre1.7.0_" + $update_Version$ + "\jre1.7.0_" + $update_Version$ + ".msi"
Set $msi64$				= "msi\jre1.7.0_" + $update_Version$ + "_x64\jre1.7.0_" + $update_Version$ + ".msi"
Set $exe32$				= "jre-7u" + $update_Version$ + "-windows-i586.exe"
Set $exe64$				= "jre-7u" + $update_Version$ + "-windows-x64.exe"
Set $LogDir$				= "%SYSTEMDRIVE%\tmp"
Set $INST_SystemType$		= GetSystemType
Set $INST_MsVersion$		= GetMsVersionInfo
Set $INST_architecture$		= GetProductProperty ("install_architecture","system specific")
Set $Path$				= "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set $Path_64$			= "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
Set $msi_suffix$			= ""
Set $DisplayName$			= $ProductId$ + " " + $DisplayVersion$
Set $DisplayVersionx32$		= $ProductId$ + " " + $DisplayVersion$ + " x32"
Set $DisplayVersionx64$		= $ProductId$ + " " + $DisplayVersion$ + " x64"
Set $msiPath$			= "%scriptdrive%\Setup_data\java\msi\"
 
ShowBitmap /3 "%scriptpath%\java.png" $ProductId$
 
if $INST_MsVersion$ < "5.1"
	LogError "Minimum Windows XP is required for Java >= 1.7" 
	isFatalError
endif
if not (HasMinimumSpace ("%SYSTEMDRIVE%", $MinimumSpace$))
	LogError "Nicht genügend freier Speicher auf %SystemDrive%, " + $MinimumSpace$ + " auf %SystemDrive% sind mindestens benötigt für " + $ProductId$
	isFatalError
endif
 
Files_copy
 
sub "%ScriptPath%\check_uninstall.ins"
 
killtask "firefox.exe"
killtask "jqs.exe"
killtask "java.exe"
killtask "javaw.exe"
 
; #############################################################################################################################################
; ################################################################### Install x64 ###################################################################
; #############################################################################################################################################
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
	Set $DisplayVersion$ = $DisplayVersionx64$
	Message "Installiere " + $DisplayVersion$
	Execwith_autoit_close_proxy "%SCRIPTPATH%\autoit3.exe" WINST /letThemGo
	Winbatch_install_x64
	Sub_check_exitcode
	if CompareDotSeparatedNumbers("%WinstVersion%","4.11.2") >= "0"
		includelog "%SYSTEMDRIVE%\tmp\" + $DisplayVersion$ + "_x64.log" "20"
	endif
	Killtask "autoit3.exe"
	DOSInAnIcon_java_version
	Registry_disable_update /64Bit
endif
 
; #############################################################################################################################################
; ################################################################### Install x32 ###################################################################
; #############################################################################################################################################
; if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
	Set $DisplayVersion$ = $DisplayVersionx32$
	Message "Installiere " + $DisplayVersion$
	killtask "firefox.exe"
	killtask "jqs.exe"
	killtask "java.exe"
	killtask "javaw.exe"
	Execwith_autoit_close_proxy "%SCRIPTPATH%\autoit3.exe" WINST /letThemGo
	Winbatch_install_x32
	Sub_check_exitcode
	if CompareDotSeparatedNumbers("%WinstVersion%", "4.11.2") >= "0"
		includelog "%SYSTEMDRIVE%\tmp\" + $DisplayVersion$ + "_x86.log" "20"
	endif
	Killtask "autoit3.exe"
	DOSInAnIcon_java_version
	Registry_disable_update
; endif
 
Files_delete
Message "Installation abgeschlossen"
 
[Winbatch_install_x32]
msiexec /i "%SYSTEMDRIVE%\tmp\$msi32$" /qb! /lie "%SYSTEMDRIVE%\tmp\$DisplayVersion$_x86.log" ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1  REBOOT=ReallySuppess SYSTRAY=0 JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0 ARPURLUPDATEINFO='http://www.opsi.org'
 
[Winbatch_install_x64]
msiexec /i "%SYSTEMDRIVE%\tmp\$msi64$" /qb! /lie "%SYSTEMDRIVE%\tmp\$DisplayVersion$_x64.log" ADDLOCAL=ALL IEXPLORER=1 MOZILLA=1  REBOOT=ReallySuppess SYSTRAY=0 JAVAUPDATE=0 JU=0 AUTOUPDATECHECK=0 ARPURLUPDATEINFO='http://www.opsi.org'
 
[DOSInAnIcon_java_version]
"%ProgramFilesDir%\java\jre7\bin\java.exe" -version
 
[Files_copy]
copy -s "$msiPath$\*.*" "%SYSTEMDRIVE%\tmp\msi"
 
[Files_delete]
delete -fs "%SYSTEMDRIVE%\tmp\msi"
 
[Execwith_autoit_close_proxy]
WinWait("Verbindung","Verbindung")
Sleep(500)
; activating
WinActivate("Verbindung","Verbindung")
send ("!{F4}")
exit
 
[Execwith_autoit_zertifikat]
WinWait("Sicherheitshinweis")
Sleep(500)
; activating
WinActivate("Sicherheitshinweis")
send ("J")
exit
 
[Registry_disable_update]
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy]
set "EnableJavaUpdate"=REG_DWORD:0
 
[Files_patch_JCE_x32]
copy -s "%SCRIPTPATH%\UnlimitedJCEPolicy\*.*" "%ProgramFiles32Dir%\Java\jre7\lib\security"
 
[Files_patch_JCE_x64]
copy -s "%SCRIPTPATH%\UnlimitedJCEPolicy\*.*" "%ProgramFiles64Dir%\Java\jre7\lib\security"
 
[Sub_check_exitcode]
comment "Test für die Installation erfolgt über Exit-Code"
Set $ExitCode$ = getLastExitCode
; Informationen zu Exit-Codes zu sehen
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
	comment "Sieht gut aus: Setup-Programm gibt Exitcode Null"
else
	comment "Setup Programm gibt einen unterschiedlichen Exitcode Null: " + $ExitCode$
	if ($ExitCode$ = "1605")
		comment "ERROR_UNKNOWN_PRODUCT	1605	Diese Aktion ist nur für Produkte gültig, die zurzeit installiert sind."
		comment "Deinstallieren eines nicht installierten Produkt fehlgeschlagen - Kein Problem"
	else
		if ($ExitCode$ = "1641")
			comment "sieht gut aus: Setup-Programm gibt exitcode 1641"
			comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	Der Installer hat einen Neustart eingeleitet. Diese Meldung weist auf einen Erfolg."
		else
			if ($ExitCode$ = "3010")
				comment "sieht gut aus: Setup-Programm gibt exitcode 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	Ein Neustart ist erforderlich, um die Installation abzuschließen. Diese Meldung weist auf einen Erfolg."
			else
				logError "Fatal: Setup-Programm gibt eine unbekannte Exitcode Null aus: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif

uninstall.ins

uninstall.ins
[Initial]
SetLogLevel=4
ExitOnError=true
ScriptErrorMessages=off
TraceMode=off
StayOnTop=false
 
[Aktionen]
requiredWinstVersion >= "4.10.8.3"
Message "Vorbereiten..."
DefVar $LogDir$
DefVar $msiPath$
DefVar $Reg_Path$
DefVar $Reg_Path_64$
DefVar $msi32$
DefVar $msi64$
DefVar $exe32$
DefVar $exe64$
DefVar $MSI$
DefVar $ExitCode$
DefVar $INST_MsVersion$
DefVar $INST_SystemType$
DefVar $INST_architecture$
DefVar $ProductId$
DefVar $UninstallCommand$
DefVar $DisplayVersion$
DefVar $DisplayName$
DefVar $DisplayVersionx32$
DefVar $DisplayVersionx64$
DefVar $MinimumSpace$
DefVar $msi_suffix$
DefVar $Path$
DefVar $Path_64$
DefVar $update_Version$
DefStringList $version6$
DefStringList $version7$
 
Set $ProductId$			= "Java"
; -------------------------------------------------------------------------------------------------------------------------------------------------------
; - Please edit the following values																	-
; -------------------------------------------------------------------------------------------------------------------------------------------------------
; Look up for new update versions of Java 6.
; https://en.wikipedia.org/wiki/Java_version_history#Java_6_updates
set $version6$				= createStringList ('10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '43', '45', '51', '65', '71')
 
; Add the new update version number to the stringlist, also add all version numbers you have skipped.
; https://en.wikipedia.org/wiki/Java_version_history#Java_7_updates
set $version7$				= createStringList ('00', '01', '02', '03', '04', '05', '06', '07', '09', '10', '11', '13', '15', '17', '21', '25', '40', '45', '51')
 
; increment the first takeString argument, by how much numbers you added to "$version7$". 
; this is used to get the last index of "$version7$"
Set $update_Version$		= takeString ( 18, $version7$ )
 
 
; -------------------------------------------------------------------------------------------------------------------------------------------------------
; - DO NOT EDIT ANY VALUES BELOW! Unless you want to edit the functionality of this.							-
; -------------------------------------------------------------------------------------------------------------------------------------------------------
Set $DisplayVersion$		= "7.0." + $update_Version$
Set $MinimumSpace$		= "123 MB"
Set $msi32$				= "msi\jre1.7.0_" + $update_Version$ + "\jre1.7.0_" + $update_Version$ + ".msi"
Set $msi64$				= "msi\jre1.7.0_" + $update_Version$ + "_x64\jre1.7.0_" + $update_Version$ + ".msi"
Set $exe32$				= "jre-7u" + $update_Version$ + "-windows-i586.exe"
Set $exe64$				= "jre-7u" + $update_Version$ + "-windows-x64.exe"
Set $LogDir$				= "%SYSTEMDRIVE%\tmp"
Set $INST_SystemType$		= GetSystemType
Set $INST_MsVersion$		= GetMsVersionInfo
Set $INST_architecture$		= GetProductProperty ("install_architecture","system specific")
Set $Path$				= "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set $Path_64$			= "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
Set $msi_suffix$			= ""
Set $DisplayName$			= $ProductId$ + " " + $DisplayVersion$
Set $DisplayVersionx32$		= $ProductId$ + " " + $DisplayVersion$ + " x32"
Set $DisplayVersionx64$		= $ProductId$ + " " + $DisplayVersion$ + " x64"
Set $msiPath$			= "%scriptdrive%\Setup_data\java\msi\"
 
ShowBitmap /3 "%scriptpath%\java.png" $ProductId$
 
sub "%ScriptPath%\check_uninstall.ins"
 
Message "Deinstallation von " + $ProductId$ + " abgeschlossen"
userspace/java-ng.1390228987.txt.gz · Last modified: 2021/08/23 08:37 (external edit)