pavel
pavel

Reputation: 2186

Install package (appxbundle) via .appinstaller to all users on machine

I use installing of my UWP application via .appinstaller file: Read more about this approach

But now the installation works only for current user. Could I somehow install my app throw .appinstaller to all users on machine?

Edit:

You have not this package on your hands. It is located at server and all you have is uri for running appinstaller file.

Thanks in advance.

Upvotes: 1

Views: 7357

Answers (2)

Swise
Swise

Reputation: 1

Five years later, chatGPT produced for me the following powershell script, which takes an AppInstaller path as a parameter and installs it for all users:

# Define the path to the AppInstaller XML File
param([String]$xmlFilePath)

# Define the directory for downloads
$downloadDirectory = "C:\AppInstallerTemp"
cmd.exe /c mkdir $downloadDirectory

# Supresses slow powershell GUI
$ProgressPreference = 'SilentlyContinue'

# Load the XML file
$xml = [xml](Get-Content $xmlFilePath)

# Get the Uri for the MainBundle
$mainBundleUri = $xml.AppInstaller.MainBundle.Uri

# Define the XML namespace
$namespaceStr = $xml.AppInstaller.xmlns
$namespace = New-Object Xml.XmlNamespaceManager($xml.NameTable)
$namespace.AddNamespace("ns", $namespaceStr)

# Download the MainBundle
$mainBundleFileName = "MainBundle.msixbundle"
$mainBundlePath = "$downloadDirectory\$mainBundleFileName"
Invoke-WebRequest -Uri $mainBundleUri -OutFile $mainBundlePath

# Get the Uri for dependencies with ProcessorArchitecture="x64"
$dependencies = $xml.SelectNodes("//ns:Dependencies/ns:Package[@ProcessorArchitecture='x64']", $namespace)

# Download and get the dependency paths for installation
$dependencyPaths = @()
foreach ($dependency in $dependencies) {
    $dependencyUri = $dependency.Uri
    $dependencyFileName = ($dependencyUri -split '/')[-1]
    $dependencyPath = "$downloadDirectory\$dependencyFileName"
    Invoke-WebRequest -Uri $dependencyUri -OutFile $dependencyPath
    $dependencyPaths += $dependencyPath
}

# Install the MainBundle and add dependencies to the dependency path list
Add-AppxProvisionedPackage -Online -PackagePath $mainBundlePath -DependencyPackagePath $dependencyPaths -SkipLicense

# Cleans up temp files
cmd.exe /c rd /s /q $downloadDirectory

# Forces install for other users
Get-AppXPackage -allusers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

Write-Host "Installation completed."

Upvotes: 0

Bogdan Mitrache
Bogdan Mitrache

Reputation: 11023

You cannot do this from a package manually installed (double clicked) by an user.

System wide deployments are available only if you use Microsoft's DISM tooling. More details:

Upvotes: 1

Related Questions