ich benutze derzeit OPSI auf einem Lubuntu und möchte gerne, dass bei der Installation einer neuen Firefox Version, dass alte Firefox automatisch deinstalliert wird.
Mit Scripten bin ich leider nicht sehr vertraut.
Ich habe nun folgendes Problem:
Die neue Firefox Version wird unter C:\Program Files\ installiert.
Die Alte Version liegt unter C:\Program Files (x86)
Im Script wird nur überprüft, ob eine alte Version im Installationsverzeichnis vorhandne ist (sprich: C:\Program Files\)
Über den Setup Detector sowie den OPSI Package builder habe ich ein Firefox Paket erstellt.
Die Scripte sehen wie folgt aus:
setup.opsiscript
Code: Alles auswählen
; ----------------------------------------------------------------
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; ----------------------------------------------------------------
[Actions]
requiredWinstVersion >= "4.12.0.28"
ScriptErrorMessages = false
DefVar $ProductId$
DefVar $InstallDir$
DefVar $MinimumSpace$
DefVar $ExitCode$
DefVar $ErrorString$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
DefVar $LogDir$
DefVar $OS$
DefVar $oldProgFound$
Set $LogDir$ = "%opsiLogDir%"
; import complete file !
importlib "uib_exitcode.opsiscript"
importlib "%scriptpath%\osd-lib.opsiscript"
; ----------------------------------------------------------------
; $ProductId$ is the name of the product in opsi, only lower letters, no umlauts, no white spaces, use '-' as a seperator
Set $ProductId$ = "firefox 74.0"
; the path where we find the product after the installation
Set $InstallDir$ = "C:\Program Files\Mozilla Firefox\"
Set $LicenseRequired$ = "False"
Set $LicensePool$ = ""
Set $MinimumSpace$ = "300 MB"
; ----------------------------------------------------------------
set $OS$ = GetOS
if not(($OS$ = "Windows_NT"))
logError "Installation aborted: wrong OS version: only Windows"
isFatalError "wrong OS"
endif
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError "No Space"
; Stop process and set installation status to failed
endif
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
if FileExists("%ScriptPath%\delsub.opsiscript")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.opsiscript"
endif
Message "Installing " + $ProductId$ + " ..."
if $LicenseRequired$ = "true"
comment "Licensing required, reserve license and get license key"
set $LicenseKey$ = get_licensekey_byPoolOrKey($LicensePool$)
endif
comment "Start setup program"
ChangeDirectory "%SCRIPTPATH%\files"
;----------------------------------------------
Winbatch_install
;----------------------------------------------
Sub_check_exitcode
[Winbatch_install]
"%scriptpath%\files\setup.exe" /S
[sub_check_exitcode]
set $ExitCode$ = getlastexitcode
if stringtobool(isNsisExitcodeFatal($exitcode$, "true", $ErrorString$ ))
LogError $ErrorString$
isfatalerror $ErrorString$
else
Comment $ErrorString$
endif
; ----------------------------------------------------------------
; ----------------------------------------------------------------
Code: Alles auswählen
; ----------------------------------------------------------------
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; ----------------------------------------------------------------
[Actions]
requiredWinstVersion >= "4.12.0.28"
ScriptErrorMessages = false
DefVar $ProductId$
DefVar $InstallDir$
DefVar $MinimumSpace$
DefVar $ExitCode$
DefVar $ErrorString$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
DefVar $LogDir$
DefVar $OS$
DefVar $oldProgFound$
Set $LogDir$ = "%opsiLogDir%"
; import complete file !
importlib "uib_exitcode.opsiscript"
importlib "%scriptpath%\osd-lib.opsiscript"
; ----------------------------------------------------------------
; $ProductId$ is the name of the product in opsi, only lower letters, no umlauts, no white spaces, use '-' as a seperator
Set $ProductId$ = "firefox 74.0"
; the path where we find the product after the installation
Set $InstallDir$ = "C:\Program Files\Mozilla Firefox\"
Set $LicenseRequired$ = "False"
Set $LicensePool$ = ""
; ----------------------------------------------------------------
set $OS$ = GetOS
if not(($OS$ = "Windows_NT"))
logError "Installation aborted: wrong OS version: only Windows"
isFatalError "wrong OS"
endif
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
Message "Uninstalling " + $ProductId$ + " ..."
if FileExists("%ScriptPath%\delsub.opsiscript")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.opsiscript"
endif
if $LicenseRequired$ = "true"
comment "Licensing required, free license used"
Sub_free_license
endif
[Sub_free_license]
comment "License management is enabled and will be used"
comment "Trying to free license used for the product"
DefVar $result$
Set $result$ = FreeLicense($LicensePool$)
; If there is an assignment of a license pool to the product, it is possible to use
; Set $result$ = FreeLicense("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; set $result$ = FreeLicense("", "", $WindowsSoftwareId$)
delsub.opsiscript
Code: Alles auswählen
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
Message "Check for existing installation of " + $ProductId$ + " ..."
comment "Start the Uninstall check:"
set $oldProgFound$ = "false"
if fileexists($installdir$+"\uninstall\helper.exe")
set $oldProgFound$ = "true"
endif
if $oldProgFound$ = "true"
Message "Uninstalling " + $ProductId$ + " ..."
comment "Start uninstall program"
ChangeDirectory "%SCRIPTPATH%\files"
;----------------------------------------------
Winbatch_uninstall /WaitForProcessEnding "Au_.exe" /TimeOutSeconds 20
;----------------------------------------------
Sub_check_exitcode_del
if not(($InstallDir$ = '') or ($InstallDir$ = 'unknown'))
Files_uninstall
endif
endif
[Winbatch_uninstall]
"$Installdir$\uninstall\helper.exe" /S
[Sub_check_exitcode_del]
set $ExitCode$ = getlastexitcode
if stringtobool(isNsisExitcodeFatal($exitcode$, "true", $ErrorString$ ))
LogError $ErrorString$
isfatalerror $ErrorString$
else
Comment $ErrorString$
endif
[Files_uninstall]
del -sf "$InstallDir$\"
del -sf "$oldProg$\"
;-----------------------------------------------------
Danke im voraus.
Viele Grüße
Erdem