预安装已打包的应用Preinstalling packaged apps

可以使用多个工具将 MSIX 打包应用安装到设备,供所有用户使用:There are multiple tools which can be used to install an MSIX packaged app to a device for all users:

  • 部署映像服务和管理 (DISM)Deployment Image Servicing and Management (DISM)
  • 预配包Provisioning Packages
  • PowerShellPowerShell

本文概述预装应用的工作原理,以及预配和许可过程如何使用预装的应用。This article will provide an overview of how preinstalled apps work and how provisioning and licenses work with preinstalled apps.

概述Overview

打包应用安装的预安装可以分为两个步骤:Preinstall of packaged app installations can be broken down into two steps:

  1. 分步Staging
  2. 注册Registration

分步Staging

将打包应用暂存到设备,是将该打包应用的副本存储到本地文件系统的操作。Staging a packaged app to a device, is the act of storing a copy of the packaged app to the local file system. 打包应用只能暂存一次,并且无需设备上拥有任何用户帐户即可执行。A packaged app must only be staged once, and can be performed without any user accounts existing on the device.

可以在脱机映像(.wim、.vhd 或 .vhdx)或联机活动操作系统上执行打包应用的暂存。The staging of a packaged app can be performed on an offline image (.wim, .vhd, or .vhdx) or an online active operating system.

注册Registration

暂存打包应用后,可以将应用注册到设备上的用户。After a packaged app has been staged, the app can then be registered to users on the device. 注册按用户进行,在设备用户登录时开始。Registration occurs on a per-user basis, and begins when a user of the device logs on. 然后,操作系统将加载预安装的打包应用包,以便在“开始”菜单中创建用户特定的应用数据、创建文件类型关联和应用磁贴。The operating system will then load the preinstalled packaged app package creating user specific app data, create file type associations, and app tiles in the start menu. 这是由应用就绪服务 (ARS) 实现的,它可以识别所有预安装的应用。This accomplished by the App Rediness Service (ARS) which is aware of all pre-installed apps.

DISMDISM

DISM 是一个命令行工具,可用于服务和准备 WIndows 映像,包括用于 Windows 预执行 (Win-PE)、恢复环境 (Win) 和 Windows 安装程序的映像。DISM is a command-line tool that can be used to service and prepare WIndows images, including those used for Windows Pre-Execution (Win-PE), Recovery Environment (Win-RE), and Windows Setup. DISM 可用来维修 Windows 映像 (.wim) 或虚拟硬盘(.vhd 或 .vhdx)。Dism can be used to service a Windows image (.wim) or virtual hard disks (.vhd, or .vhdx).

预配包Provisioning packages

所有应用预配封装在 DISM 工具中,会同时执行暂存和 ARS 设置。All app provisioning is encapsulated within the DISM tool, and it does both the staging and ARS setup. 若要执行预配,IT 专业人员需要一个应用包(.msix、.msixbundle、.appx 或 .appxbundle)和任何依赖项包。To do provisioning, the IT Pro needs an app package (.msix, .msixbundle, .appx or .appxbundle) and any dependency packages.

从 Windows 10 1809 开始,IT 专业人员可以通过预配进行预安装。Beginning with Windows 10 1809, IT Pros can pre-install through provisioning. 预配的应用将安装到中心位置 %ProgramFiles%\WindowsApps,并且将立即可供注册用户使用。Provisioned apps will be installed to a central location: %ProgramFiles%\WindowsApps and will immediately be available to registered users. 只有将 MSIX 应用包注册到其帐户的用户才能访问该应用。Only users with the MSIX app package registered to their account will have access to the app.

在 Windows 10 2004 中,将在重新预配期间重新安装预配的打包应用。In Windows 10 2004, a provisioned packaged app will reinstall during re-provisioning. 如果用户以前卸载了打包应用,以前版本的 Windows 10 会阻止重新安装这些打包应用。Prior versions of Windows 10 would prevent the reinstall of these packaged apps if the user had previously uninstalled the packaged app.

PowerShellPowerShell

相关 PowerShell 命令的列表List of relevant PowerShell commands

  • Get-ProvisionedAppxPackages 此命令列出映像中预装的所有应用的列表。Get-ProvisionedAppxPackages This will list all of the apps that are pre-installed on the image.
  • Add-ProvisionedAppxPackage 此命令暂存 appx 包,并对其进行配置,以便可以预装。Add-ProvisionedAppxPackage This stages the appx package and configures it for pre-install. 还必须提供所有依赖项,可以在 SDK 或者从 Store 下载的包中找到这些依赖项。All dependencies must be provided as well, which can be found in the SDK or with store-downloaded packages.
  • /Remove-ProvisionedAppxPackage 此命令可用于删除预装的应用。Remove-ProvisionedAppxPackage This can be used to remove a pre-installed app. 请注意,如果已经为任何用户注册了应用,则此命令不会删除该应用 - 只会去掉自动注册行为,因此不会为任何新用户自动安装该应用。Note that it does not remove the app if it is already registered for any users - this only strips the auto-registration behavior so it will not be auto-installed for any new users. 如果没用任何用户安装该应用,则此命令还会删除暂存的文件。If no users have yet installed the app, this command will also remove the staged files.

授权Licensing

仅当预配 Windows Store 应用时,许可才适用。Licensing only applies when provisioning a Windows Store app. 任何其他应用无需许可证即可预配。Any other apps can be provisioned without a license. 如果应用来自于 Store,则预配该应用时,还必须提供机器许可证。If an app is from the Store a machine-license must also provided when the app is provisioned. 目前,所有预装的 Windows Store 应用必须是免费应用,并配置为可通过 Windows Store 合作伙伴中心预装。At this time, all preinstall Windows Store apps must be free apps and configured to be pre-installable via the Windows Store Partner Center. 配置后,可以下载可预装的包和许可证,然后将其预配到任何映像中。Once it is configured the pre-installable package and license can be downloaded and then provisioned onto any image.