Seite 1 von 1
Paketinstallation Prozess prüfen und Informieren
Verfasst: 02 Sep 2025, 09:50
von SportUserNRW
Hallo zusammen,
Ich habe ein Problem bei der Installation/Update einer Software. Wenn ich "ON-Demand" eine Installation starte, bricht die Installation ab, wenn die Software aktuell gestartet ist. Ich möchte aber nun nicht mit killtask hingehen und den Prozess beenden, da ich nicht weiß, ob es nichtgespeicherte Daten gibt.
Gibt es eine Möglichkeit dem User mittzueilen, dass er bitte die Software beenden soll und somit die Daten gespeichert sind?
Im Anschluss könnte er auf OK klicken und die Installation wird fortgesetzt.
Ich habe öfters den Fall, dass Installationen auf FAILED gehen.
Schönen Gruß
Dirk
Re: Paketinstallation Prozess prüfen und Informieren
Verfasst: 02 Sep 2025, 11:08
von thomas.besser
Ja, das kannst du selbst in OPSI-Skript bewerkstelligen. Was fertiges dazu gibt es nicht. Hier mal die Funktion von o4i...
Code: Alles auswählen
DefFunc checkRunningProcess(val $Exe$ : string, val $ProductName$ : string, val $Language$ : string) : void
;@author Thomas Besser
;@email thomas.besser@kit.edu
;@date 30.06.2020
;@copyright AGPLv3
;@version 1.1
;@Description Check what to do if application is running while uninstallation is initiated by kiosk or on_demand (https://wiki.o4i.org/index.php/Richtlinien#Running_Process[see o4i wiki]). For own messages create files according `RunningProcess_<language>.msg` in `custom` directory. Possible placeholders `{Exe}` and `{ProductName}` will be replaced.
;@Returns nothing (void)
;@ParamDesc_$Exe$ Name of binary which should not be running
;@ParamDesc_$ProductName$ Productname according to `$Exe$`
;@ParamDesc_$Language$ Language (`de`|`en`) in which the message should be shown, if empty then system language will be detected
;@Example [actions]
;@Example DefVar $Exe$
;@Example DefVar $ProductName$
;@Example DefVar $InstalledVersion$
;@Example Set $Exe$ = "testapp.exe"
;@Example Set $ProductName$ = "TestApp"
;@Example checkRunningProcess($Exe$, $ProductName$, "")
DefVar $ErrorString$
DefVar $Property$
DefVar $Message$
DefVar $MessageFile$
Set $Property$ = GetProductProperty("running_process", "inform")
; falls Parameter Language leer sein sollte, dann Systemsprache ermitteln
if ($Language$ = "")
set $Language$ = lower(getValue("language_id_2chars", GetLocaleInfoMap))
endif
; checken ob Anwendung läuft (z.B. bei Upgrade über Kiosk) und entsprechend ProductProperty handeln
if ProcessIsRunning($Exe$)
comment "Running process of application found!"
Switch $Property$
Case "kill"
comment "Killing process '" + $Exe$ + "'"
killtask $Exe$
EndCase
Case "defer"
; Paket auf deferred setzen und script beenden
comment "Deferring action and abort script execution at this point"
set $Result$ = currentProductSetReport("deferred: exe is running")
;Skript beenden (inkl. evtl. update-Skript)
isSuspended
noUpdateScript
EndCase
Case "inform"
comment "Inform the user and ask for stopping the application"
; den eingeloggten User bitten, den 'störenden' Prozess / Anwendung zu schliessen.
Set $MessageFile$ = "%ScriptPath%\custom\RunningProcess_" + $Language$ + ".msg"
; exisitiert 'RunningProcess_<language>.msg', dann verwenden; andernfalls fixe Nachricht verwenden
if FileExists($MessageFile$)
Set $Message$ = takeString(0, loadunicodetextfile($MessageFile$))
else
if ($Language$ = "de")
Set $Message$ = "Die angeforderte (De-)Installation kann nicht durchgeführt werden, solange der Prozess '{Exe}' läuft. Bitte die Anwendung '{ProductName}' schließen und den Vorgang fortsetzen. Sollte der Prozess danach immer noch laufen, wird die angeforderte Aktion abgebrochen und zurückgesetzt."
else
;fallback to 'en
Set $Message$ = "The requested (un-)installation cannot be done as long as a process '{Exe}' is running. Please stop the application '{ProductName}' and continue this procedure. If the process afterwards is still running, the requested action will be stopped and reset."
endif
endif
Set $Message$ = stringReplace($Message$, "{Exe}", $Exe$)
Set $Message$ = stringReplace($Message$, "{ProductName}", $ProductName$)
Pause $Message$
if ProcessIsRunning($Exe$)
comment "Process of application is still running. Set an appropiate report, stop this script, reset the action"
logWarning "Informed the actual user to stop the application before proceeding. But it is still running, so aborting this script without doing anything."
; reset und 'setup' wieder entfernen; script beenden
Set $ErrorString$ = productSetActionRequest("%installingProdName%", "none")
Set $ErrorString$ = currentProductSetReport("reset: exe still running")
;Skript beenden (inkl. evtl. update-Skript)
isSuspended
noUpdateScript
endif
EndCase
EndSwitch
endif
endfunc