====== Java ======
Thanks to Der-Matze \\
Comments and improvements welcome \\
Tested with opsi 4.0.1 \\
Tested with opsi-winst 4.10.x - 4.11.1.6 \\
Tested with Windows XP Professional\\
This script uses the check_msi-exitcode script: https://forum.opsi.org/wiki/userspace:check_msi-exitcode \\
Uninstall.ins deinstalls all Versions of Java from 1.5.0.x until 1.6.0.31.\\
Because of the nesting of the subs, it is not possible to outsource the code in subuninstall.ins\\
===== install.ins =====
[Initial]
;Standard Text, der während der Installation angezeigt wird
Message = Bitte warten, das Produkt wird installiert
;Loglevel einstellen
setLogLevel = 6
;Bei Fehlern abbrechen
ExitOnError = false
;Syntax Fehler werden in einem separaten Fenster angezeigt
ScriptErrorMessages = on
;Single-Step Mode nicht verwenden
TraceMode = off
;Im Batchmode das Winst-Fenster nicht im Vordergrund anzeigen
StayOnTop = false
[Actions]
;Variable für die Ermittlung des Betriebssystems
DefVar $OS$
set $OS$ = GetOS
;Variable für die Ermittlung der Betriebssystem Unterversion
DefVar $NTVersion$
set $NTVersion$ = GetNTVersion
;Variable zur Ermittlung der Systemarchitektur
DefVar $SystemType$
Set $SystemType$ = GetSystemType
;Name des Produkts (max. 12 Zeichen)
DefVar $ProductName$
Set $ProductName$ = "Java"
;Vollständiger Produktname incl. Versionsnummer
DefVar $ProductNameFull1$
set $ProductNameFull1$ = "Java 1.6 Update 31"
;Dateiname des Produktbildes mit Erweiterung
DefVar $ProductPicture$
Set $ProductPicture$ = "Java.png"
DefVar $Executable32$
DefVar $Executable64$
Set $Executable32$ = "jre-6u31-windows-i586-s.exe"
Set $Executable64$ = "jre-6u31-windows-x64.exe"
;Die Variable zur Auswertung des ExitCodes
DefVar $ExitCode$
;Prüfen der Winst Version
requiredWinstVersion >= "4.11"
;$ProductPicture$ und $ProductName$ anzeigen
ShowBitmap /3 "%scriptpath%\" + $ProductPicture$ $ProductName$
;Anzeigen der Installationsbenachrichtigung incl. des vollen Produktnamens
Message "Installiere "+$ProductNameFull1$
;Freien Speicherplatz ermitteln
if not (HasMinimumSpace ("%SYSTEMDRIVE%", "100 MB"))
LogError "Nicht genügend Platz auf %SYSTEMDRIVE%"
isFatalError
endif
;OS-Version ermitteln
if ( $NTVersion$ = "Win2K" OR $NTVersion$ = "WinXP" OR $NTVersion$ = "Win NT 5.2" OR $NTVersion$ = "Windows Vista" )
if $SystemType$ = "x86 System"
Winbatch_Install_32-Bit
endif
if $SystemType$ = "64 Bit System"
Winbatch_Install_64-Bit
endif
else
LogError "Kein kompatibles Betriebssystem installiert"
isFatalError
endif
[Winbatch_Install_32-Bit]
msiexec /i "%SCRIPTPATH%\$Executable32$" /qb-! reboot=reallysuppress
[Winbatch_Install_64-Bit]
msiexec /i "%SCRIPTPATH%\$Executable64$" /qb-! reboot=reallysuppress
===== uninstall.ins =====
[Initial]
Message = Bitte warten, Java wird Deinstalliert
setLogLevel = 6
ExitOnError = false
ScriptErrorMessages = on
TraceMode = off
StayOnTop = false
[Actions]
;Variable for the OS
DefVar $OS$
Set $OS$ = GetOS
;Variable for the OS-subversion
DefVar $NTVersion$
Set $NTVersion$ = GetNTVersion
;Name of product (max. 12 columns)
DefVar $ProductName$
Set $ProductName$ = "java"
;filename of productpicture with extension
DefVar $ProductPicture$
Set $ProductPicture$ = "java.png"
;the variable for the ExitCode
DefVar $ExitCode$
;show $ProductPicture$ and $ProductName$
ShowBitmap /3 "%scriptpath%\" + $ProductPicture$ $ProductName$
;Variable for the msiexec-call for deinstallation
DefVar $UninstallCommand$
;Variable for the current version. Will be read from registry.
DefVar $DisplayName$
;Stingliste for the different Versions of Java
DefStringList $version15$
DefStringList $version16_1$
DefStringList $version16_2$
DefStringList $version16_3$
set $version15$ = createStringList ('01','02', '03', '04', '05', '06', '07','08', '09', '10', '11', '12', '13','14', '15', '16','17', '18', '19', '20', '21', '22')
set $version16_1$ = createStringList ('01','02', '03', '04', '05', '06', '07')
;there is no Java 1.6.0 Update 8 or 9
;there are different Uninstall-Strings betweeen Version 10 and Version 20 (ends with F0)
set $version16_2$ = createStringList ('10', '11', '12', '13', '14', '15', '16', '17' , '18' , '19' , '20')
;Uninstall String (ends with FF)
set $version16_3$ = createStringList ('10','11', '12', '13', '14', '15', '16', '17' , '18' , '19' , '20', '21', '22' , '23' , '24' , '25', '26', '27' , '28' , '29' , '30', '31')
killtask "java.exe"
killtask "javaw.exe"
killtask "jqs.exe"
for $x$ in $version15$ do sub_patch_uninstall_15
for $x$ in $version16_1$ do sub_patch_uninstall_16_1
for $x$ in $version16_2$ do sub_patch_uninstall_16_2
for $x$ in $version16_3$ do sub_patch_uninstall_16_3
[sub_patch_uninstall_15]
;Java 1.5.0.XX deinstallieren
Set $DisplayName$ = GetRegistrystringvalue32("[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3248F0A8-6813-11D6-A77B-00B0D0150$x$0}] DisplayName")
if not ($DisplayName$ = "")
Message "Deinstalling "+$DisplayName$
set $UninstallCommand$ = "MsiExec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0150$x$0} /qb-! REBOOT=ReallySuppress"
Winbatch_Uninstall
sub "%ScriptDrive%\install\check_exitcode\check_msi-exitcode.ins"
endif
[Winbatch_Uninstall]
$UninstallCommand$
[sub_patch_uninstall_16_1]
;Java 1.6.0.XX deinstallieren
Set $DisplayName$ = GetRegistrystringvalue32("[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3248F0A8-6813-11D6-A77B-00B0D0160$x$0}] DisplayName")
if not ($DisplayName$ = "")
Message "Deinstalling "+$DisplayName$
set $UninstallCommand$ = "MsiExec.exe /x {3248F0A8-6813-11D6-A77B-00B0D0160$x$0} /qb-! REBOOT=ReallySuppress"
Winbatch_Uninstall
sub "%ScriptDrive%\install\check_exitcode\check_msi-exitcode.ins"
endif
[sub_patch_uninstall_16_2]
;Java 1.6.0.XX deinstallieren
Set $DisplayName$ = GetRegistrystringvalue32("[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F832160$x$F0}] DisplayName")
if not ($DisplayName$ = "")
Message "Deinstalling "+$DisplayName$
set $UninstallCommand$ = "MsiExec.exe /x {26A24AE4-039D-4CA4-87B4-2F832160$x$F0} /qb-! REBOOT=ReallySuppress"
Winbatch_Uninstall
sub "%ScriptDrive%\install\check_exitcode\check_msi-exitcode.ins"
endif
[sub_patch_uninstall_16_3]
;Java 1.6.0.XX deinstallieren
Set $DisplayName$ = GetRegistrystringvalue32("[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F832160$x$FF}] DisplayName")
if not ($DisplayName$ = "")
Message "Deinstalling "+$DisplayName$
set $UninstallCommand$ = "MsiExec.exe /x {26A24AE4-039D-4CA4-87B4-2F832160$x$FF} /qb-! REBOOT=ReallySuppress"
Winbatch_Uninstall
sub "%ScriptDrive%\install\check_exitcode\check_msi-exitcode.ins"
endif