Views
WinstScripts
>>
acroread
last edited 3 months ago by sehlers
Qualified opsi 3.4
You have three scripts for installing (setup.ins), updateing (update.ins and deleting (delsub.ins) the acroreader
setup.ins
**************************************************************
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Initial]
requiredWinstVersion >= "4.8.6"
LogLevel=2
; Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; Let started programs run in front of the winst window
StayOnTop=false
[Aktionen]
DefVar $TEMP$
Set $TEMP$ = EnvVar("TEMP")
DefVar $LogDir$
Set $LogDir$ = "%SystemDrive%\tmp"
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $NewExe$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
Set $ProductId$ = "acroread9"
Set $MinimumSpace$ = "350 MB"
Set $InstallDir$ = "%ProgramFilesDir%\Adobe\Reader 9.0"
Set $NewExe$ = $InstallDir$ + "\Reader\acrord32.exe"
Set $LicenseRequired$ = "false"
Set $LicensePool$ = "p_" + $ProductId$
; ----------------------------------------------------------------
DefStringList $LanguageInfo$
DefVar $ThreeLetterLanguageCode$
DefVar $MsiFile$
DefVar $MstFile$
DefVar $UpdaterDirectory$
comment "Testing system language"
Set $LanguageInfo$ = getLocaleInfo
; we have a 5 elements String List. In the log file we get
; retrieving strings from getLocaleInfo:
; (string 0)DE
; (string 1)DEU
; (string 2)German
; (string 3)Germany
; (string 4)0407
; We may now construct scripts for conditionial statements (cf. section 6.7) like
Set $ThreeLetterLanguageCode$ = takeString(1, $languageInfo$)
comment "System language is: " + $ThreeLetterLanguageCode$
if (($ThreeLetterLanguageCode$ = "DEU") or ($ThreeLetterLanguageCode$ = "DES"))
Set $MsiFile$ = "%ScriptPath%\files\AdbeRdr930_de_DE.msi"
Set $MstFile$ = "%ScriptPath%\files\AdbeRdr930_de_DE.mst"
Set $UpdaterDirectory$ = "%ProgramFilesDir%\Gemeinsame Dateien\Adobe\Updater6\"
else
if ($ThreeLetterLanguageCode$ = "ENU")
Set $ThreeLetterLanguageCode$ = "ENU"
Set $MsiFile$ = "%ScriptPath%\files\AdbeRdr930_en_US.msi"
Set $MstFile$ = "%ScriptPath%\files\AdbeRdr930_en_US.mst"
Set $UpdaterDirectory$ = "%ProgramFilesDir%\Common Files\Adobe\Updater6\"
else
; Fallbacklanguage
;
Set $ThreeLetterLanguageCode$ = inivar("fallbacklanguage")
if (($ThreeLetterLanguageCode$ = "DEU") or ($ThreeLetterLanguageCode$ = "DES"))
Set $MsiFile$ = "%ScriptPath%\files\AdbeRdr930_de_DE.msi"
Set $MstFile$ = "%ScriptPath%\files\AdbeRdr930_de_DE.mst"
Set $UpdaterDirectory$ = "%ProgramFilesDir%\Gemeinsame Dateien\Adobe\Updater6\"
else
if ($ThreeLetterLanguageCode$ = "ENU")
Set $MsiFile$ = "%ScriptPath%\files\AdbeRdr930_en_US.msi"
Set $MstFile$ = "%ScriptPath%\files\AdbeRdr930_en_US.mst"
Set $UpdaterDirectory$ = "%ProgramFilesDir%\Common Files\Adobe\Updater6\"
endif
endif
endif
endif
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap /3 "%ScriptPath%\" + $ProductId$ + ".png" "Adobe Reader 9"
if FileExists("%ScriptPath%\delsub.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.ins"
endif
Message "Installing Adobe Reader 9 ..."
if not ($LicenseRequired$ = "false")
comment "Licensing required, reserve license and get license key"
Sub_get_licensekey
endif
comment "Start setup program"
Winbatch_install
Sub_check_exitcode
comment "Delete shortcut from desktop"
LinkFolder_delete_dektop_shortcut
if FileExists($UpdaterDirectory$)
comment "Delete updater"
Files_delete_updater_directory
endif
comment "Setting acroread (older version) to not_installed"
DefVar $UninstallProductId$
DefVar $InstallationStatus$
DefVar $ActionRequest$
DefVar $ClientId$
DefVar $DnsDomainName$
DefStringList $ServiceResult$
Set $UninstallProductId$ = 'acroread'
Set $InstallationStatus$ = 'not_installed'
Set $ActionRequest$ = 'none'
Set $ServiceResult$ = getReturnListFromSection('opsiServiceCall_getDomain')
Set $DnsDomainName$ = takestring(0, $ServiceResult$)
Set $ClientId$ = lower(EnvVar("COMPUTERNAME")) + "." + $DnsDomainName$
opsiServiceCall_setProductInstallationStatus
opsiServiceCall_setActionRequestStatus
if FileExists("%ScriptPath%\custom_ins_dir\custom.ins")
comment "Running custom specific sub"
Sub "%ScriptPath%\custom_ins_dir\custom.ins"
endif
comment "Test for installation success"
if not(FileExists($NewExe$))
logError "Fatal: After Installation '" + $NewExe$ + "' not found"
isFatalError
endif
if ( inivar("desctopicon") = "on" )
LinkFolder_Desktop_AcrobatReader
endif
ExitWindows /RebootWanted
endif
[Winbatch_install]
msiexec /i "$MsiFile$" TRANSFORMS="$MstFile$" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES
[LinkFolder_delete_dektop_shortcut]
set_basefolder common_desktopdirectory
set_subfolder ""
delete_element "Adobe Reader 9"
[Files_delete_updater_directory]
delete -sf "$UpdaterDirectory$"
[Sub_get_licensekey]
if opsiLicenseManagementEnabled
comment "License management is enabled and will be used"
comment "Trying to get a license key"
Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
; If there is an assignment of exactly one licensepool to the product the following call is possible:
; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use:
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
DefVar $ServiceErrorClass$
set $ServiceErrorClass$ = getLastServiceErrorClass
comment "Error class: " + $ServiceErrorClass$
if $ServiceErrorClass$ = "None"
comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
else
if $ServiceErrorClass$ = "LicenseConfigurationError"
LogError "Fatal: license configuration must be corrected"
LogError getLastServiceErrorMessage
isFatalError
else
if $ServiceErrorClass$ = "LicenseMissingError"
LogError "Fatal: required license is not supplied"
isFatalError
endif
endif
endif
else
LogError "Fatal: license required, but license management not enabled"
isFatalError
endif
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
[opsiServiceCall_getDomain]
"method": "getDomain"
"params": [
]
[opsiServiceCall_setProductInstallationStatus]
"method": "setProductInstallationStatus"
"params": [
"$UninstallProductId$",
"$ClientId$",
"$InstallationStatus$"
]
[opsiServiceCall_setActionRequestStatus]
"method": "setProductActionRequest"
"params": [
"$UninstallProductId$",
"$ClientId$",
"$ActionRequest$"
]
[LinkFolder_Desktop_AcrobatReader]
set_basefolder common_desktopdirectory
set_subfolder ""
set_link
name: Adobe Reader 9
target: $NewExe$
parameters:
working_dir:
icon_file:
icon_index:
end_link
***************************************************************
update.ins
***************************************************************
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Initial]
requiredWinstVersion >= "4.8.6"
LogLevel=2
; Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; Let started programs run in front of the winst window
StayOnTop=false
[Aktionen]
DefVar $LogDir$
DefVar $ProductId$
DefStringList $UpdateVersions$
Set $LogDir$ = "%SystemDrive%\tmp"
Set $ProductId$ = "acroread9"
;Set $UpdateVersions$ = createStringList('911', '912', '913', '931')
comment "Show product picture"
ShowBitmap /3 "%ScriptPath%\" + $ProductId$ + ".png" "Adobe Reader 9"
Message "Updating Adobe Reader 9 ..."
WinBatch_update
;for $version$ in $UpdateVersions$ do Winbatch_update
[WinBatch_update]
;msiexec /p "%ScriptPath%\files\AdbeRdrUpd$version$_all_incr.msp" /qn /l* "$LogDir$\$ProductId$.update-$version$-log.txt"
msiexec /p "%ScriptPath%\files\AdbeRdrUpd931_all_incr.msp" /qn /l* "$LogDir$\$ProductId$.update-931-log.txt"
msiexec /p "%ScriptPath%\files\AdbeRdrUpd932_all_incr.msp" /qn /l* "$LogDir$\$ProductId$.update-932-log.txt"
**********************************************************************
delsub.ins
**********************************************************************
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
DefVar $MsiId$
Message "Uninstalling Adobe Reader 9 ..."
; Acrobat Reader 9.3 - DEU
Set $MsiId$ = '{AC76BA86-7AD7-1031-7B44-A93000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
; Acrobat Reader 9.3 - ENU
Set $MsiId$ = '{AC76BA86-7AD7-1033-7B44-A93000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
; Acrobat Reader 9.2 - DEU
Set $MsiId$ = '{AC76BA86-7AD7-1031-7B44-A92000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
; Acrobat Reader 9.2 - ENU
Set $MsiId$ = '{AC76BA86-7AD7-1033-7B44-A92000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
; Acrobat Reader 9.1.3 - DEU
Set $MsiId$ = '{AC76BA86-7AD7-1031-7B44-A91000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
; Acrobat Reader 9.1.3 - ENU
Set $MsiId$ = '{AC76BA86-7AD7-1033-7B44-A91000000001}'
if not (GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
[Winbatch_uninstall_msi]
msiexec /x $MsiId$ /qb! REBOOT=ReallySuppress
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif