MSIX Anwendungen per OPSI installieren.
Verfasst: 21 Okt 2024, 13:22
Hallo zusammen,
gibt es eine Möglichkeit, MSIX Anwendungen per OPS zu installieren ?
gibt es eine Möglichkeit, MSIX Anwendungen per OPS zu installieren ?
Code: Alles auswählen
DefVar $ExitCode$
DefVar $Setupfile$
DefVar $InstallString$
DefVar $AppXPackageName$
DefVar $RemoveAppxProvisionedPackage$
DefVar $RemoveAppxPackage$
; Hier wird alles für die Installation ausgefüllt:
Set $Setupfile$ = 'pfad/zum/setupfile'
Set $InstallString$ = 'Add-AppxProvisionedPackage -Online -SkipLicense -PackagePath '+$Setupfile$
; Hier wird alles für die Deinstallation ausgefüllt:
Set $AppXPackageName$ = ' Displayname der Anwendung mit Get-AppxProvisionedPackage -Online oder Get-AppxPackage -Allusers ermitteln'
Set $RemoveAppxProvisionedPackage$ = 'Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -like "*'+$AppXPackageName$+'*"} | Remove-AppxProvisionedPackage -Online'
Set $RemoveAppxPackage$ = 'Get-AppxPackage -Allusers -Name *'+$AppXPackageName$+'* | Remove-AppxPackage -AllUsers -Confirm:$False'
Code: Alles auswählen
Set $Exitcode$ = powershellcall($RemoveAppxProvisionedPackage$)
Set $Exitcode$ = powershellcall($RemoveAppxPackage$)
Code: Alles auswählen
Set $Exitcode$ = powershellcall($InstallString$)
Code: Alles auswählen
; ----------------------------------------------------------------
; This is a opsi-script file.
; See https://opsi.org https://uib.de
; This code was originally created by opsi-setup-detector 4.3.3.2
; ----------------------------------------------------------------
encoding=utf8
; ---------------------------------------------------------------
comment "check if there is something to uninstall"
; ----------------------------------------------------------------
Message "Check for existing installation of " + $ProductId$ + " ..."
comment "Start the Uninstall check:"
set $oldProgFound$ = "false"
set $UninstallList$ = powershellCall("Get-AppxPackage -AllUsers -Name 3CXDMCC.3CX | select -expandProperty PackageFullName")
; remove empty entries
set $UninstallList$ = removeFromListByMatch("", $UninstallList$)
if count($UninstallList$) int> "0"
set $MsixAppxPackageName$ = takeString(0,$UninstallList$)
set $oldProgFound$ = "true"
endif
if $oldProgFound$ = "true"
; ---------------------------------------------------------------
comment "run the uninstall program"
; ----------------------------------------------------------------
Message "Uninstalling " + $ProductId$ + " ..."
comment "Start uninstall program"
;----------------------------------------------
Winbatch_uninstall_1 /sysnative
;----------------------------------------------
; ---------------------------------------------------------------
comment "check the result"
; ----------------------------------------------------------------
; check the outcome of the call, produce either a "failed" state of the script or log the result
set $ExitCode$ = getlastexitcode
if "true" = isGenericExitcodeFatal($exitcode$, "true", $ErrorString$ )
LogError $ErrorString$
isfatalerror $ErrorString$
else
Comment $ErrorString$
endif
; ---------------------------------------------------------------
comment "cleanup installation directory"
; ----------------------------------------------------------------
if not(($InstallDir$ = '') or ($InstallDir$ = 'unknown'))
Files_uninstall
endif
endif
;-----------------------------------------------------
Code: Alles auswählen
Set $AppInstallDir$ = getValueBySeparator("InstallLocation",":",powershellcall('Get-AppxPackage -AllUsers -Name *3cx*'))
if FileExists($AppInstallDir$)
Set $ExitCode$ = powershellcall('Get-AppxPackage -AllUsers -Name *3cx* | Remove-AppxPackage -AllUsers -Confirm:$False')
if not($ExitCode$ = "0")
isfatalerror "Error by Uninstall!"
endif
endif
Code: Alles auswählen
; ----------------------------------------------------------------
; This is a opsi-script file.
; See https://opsi.org https://uib.de
; This code was originally created by opsi-setup-detector 4.3.3.2
; ----------------------------------------------------------------
encoding=utf8
;here we start
[Actions]
;check if the running opsiscript version is not too old
requiredOpsiscriptVersion >= "4.12.5.0"
;fetch helper libraries
importlib "uib_exitcode.opsiscript"
importlib "osd-lib.opsiscript"
; All variables are defined here:
include_insert "declarations.opsiinc"
; All sections are defined here:
include_append "sections.opsiinc"
; ----------------------------------------------------------------
comment "put fixed infos into the script (maybe produced by the setup detector maybe manually)"
; ----------------------------------------------------------------
; the values can be manually edited or automatically suggested by the opsi setup detector
;
; ----------------------------------------------------------------
; $ProductId$ is the name of the product in opsi, only lower letters, no umlauts, no white spaces, use '-' as a separator
Set $ProductId$ = "3cx"
; the path where we find the product after the installation
Set $InstallDir$ = "unknown"
set $targetprogram$ = ""
Set $MinimumSpace$ = "692 MB"
; ----------------------------------------------------------------
; the operating system, in which the interpreter is running
; supported values are "Windows_NT", "Linux", "MacOS"
set $OS$ = GetOS
Message "Installing " + $ProductId$ + " ..."
; ----------------------------------------------------------------
comment "check if the script is adequate to the environment"
; ----------------------------------------------------------------
if not(($OS$ = "Windows_NT"))
logError "Installation aborted: wrong OS version: only Windows"
isFatalError "wrong OS"
; Stop process and set installation status to failed
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 "inform the user at the PC about product installation"
; ----------------------------------------------------------------
; for a better visual appearance, show some graphic (at most of size 160x160 [px] )
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
set $installerSourceDir$ = "%scriptpath%\files1"
if FileExists("%ScriptPath%\delinc.opsiinc")
comment "Start uninstall part"
include_insert "%ScriptPath%\delinc.opsiinc"
endif
Message "Installing " + $ProductId$ + " ..."
; ---------------------------------------------------------------
comment "run the setup program"
; ----------------------------------------------------------------
; the call to the installer is more stable if we set the path
ChangeDirectory $installerSourceDir$
;----------------------------------------------
Winbatch_install_1 /sysnative
;----------------------------------------------
; ---------------------------------------------------------------
comment "check the result"
; ----------------------------------------------------------------
; check the outcome of the call, produce either a "failed" state of the script or log the result
set $ExitCode$ = getlastexitcode
if "true" = isGenericExitcodeFatal($exitcode$, "true", $ErrorString$ )
LogError $ErrorString$
isfatalerror $ErrorString$
else
Comment $ErrorString$
endif
; ----------------------------------------------------------------
; ----------------------------------------------------------------
Code: Alles auswählen
DefVar $PathtoSetupFile$
Set $PathtoSetupFile = "\pfad\zu\datei\{appx/msix}"
Set $Exitcode$ = powershellcall(''Add-AppxProvisionedPackage -Online -SkipLicense -PackagePath '+$PathtoSetupFile $')
if not($ExitCode$ = "0")
isfatalerror "Error by Install!"
endif