-api-id | -api-type |
---|---|
M:Windows.Management.Deployment.PackageManager.ProvisionPackageForAllUsersAsync(System.String) |
winrt method |
Enables an app Package to be installed for all users on a device.
The FamilyName of the app package to be installed.
The progress and the result of the app package deployment.
To provision a package you must be an administrator. The app package to be provisioned must be staged, and it must be on the system volume.
If the package is already provisioned, this performs a "clean" reprovision. A "clean" reprovision will remove all previous installs of this package so the package will behave as if this were its first installation.
Note
If you are provisioning optional packages, you must specify each optional package individually with its own method call. Starting with Windows Build 22000, you can use the overload of ProvisionPackageForAllUsersAsync, to specify additional optional packages to install with a single call.
This example demonstrates adding a staged or existing registered package for all users on a device.
using Windows.Foundation;
using Windows.Management.Deployment;
public void provisionForAllUsers(string inputPackageFamilyName)
{
var packageManager = new PackageManager();
var result = packageManager.ProvisionPackageForAllUsersAsync(inputPackageFamilyName).AsTask().Result;
if (result.ExtendedErrorCode != null)
{
System.Console.WriteLine("Error {0} provisioning {1}", result, inputPackageFamilyName);
throw result.ExtendedErrorCode.HResult;
}
}