預先安裝已封裝的應用程式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. 這是由 App Rediness Service (ARS) 完成,ARS 知道所有預先安裝的應用程式。This accomplished by the App Rediness Service (ARS) which is aware of all pre-installed apps.

DISMDISM

DISM 是一種命令列工具,可用來服務和準備 WIndows 映像,包括用於 Windows Pre-Execution (Win-PE)、Recovery Environment (Win-RE)、Windows Setup 的映像。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 中或使用市集下載的套件找到這些相依性。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 市集應用程式時。Licensing only applies when provisioning a Windows Store app. 任何其他應用程式無需授權即可進行佈建。Any other apps can be provisioned without a license. 如果應用程式來自 Microsoft Store,則在佈建應用程式時也須提供電腦授權。If an app is from the Store a machine-license must also provided when the app is provisioned. 目前,所有預先安裝的 Windows 市集應用程式都必須是免費的應用程式,並設定為可透過 Windows 市集合作夥伴中心預先安裝。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.