使用 WinAppDeployCmd.exe 工具安裝應用程式Install apps with the WinAppDeployCmd.exe tool

Windows 應用程式部署 (WinAppDeployCmd.exe) 是一個命令列工具,可以用來從 Windows 10 電腦將通用 Windows 平台 (UWP) 應用程式部署到任何 Windows 10 裝置。Windows Application Deployment (WinAppDeployCmd.exe) is a command line tool that can use to deploy a Universal Windows Platform (UWP) app from a Windows 10 PC to any Windows 10 device. 當 Windows 10 裝置是透過 USB 連接,或可在相同的子網路上使用而不需要 Microsoft Visual Studio 或該應用程式適用的方案時,您就可以使用此工具來部署應用程式套件。You can use this tool to deploy an app package when the Windows 10 device is connected by USB or available on the same subnet without needing Microsoft Visual Studio or the solution for that app. 您也可以不用封裝就將 App 部署到遠端的電腦或 Xbox One。You can also deploy the app without packaging first to a remote PC or Xbox One. 本文章說明如何使用此工具安裝 UWP app。This article describes how to install UWP apps using this tool.

您只需要安裝 Windows 10 SDK,即可從命令提示字元或指令碼檔案執行 WinAppDeployCmd 工具。You just need the Windows 10 SDK installed to run the WinAppDeployCmd tool from a command prompt or a script file. 當您使用 WinAppDeployCmd.exe 安裝應用程式時,此工具會使用 .appx/.msix 檔案或 AppxManifest (用於鬆散檔案) 將您的應用程式側載到 Windows 10 裝置。When you install an app with WinAppDeployCmd.exe, this uses the .appx/.msix file or AppxManifest(for loose files) to side-load your app onto a Windows 10 device. 此命令不會安裝您 App 所需的憑證。This command does not install the certificate required for your app. 若要執行應用程式,Windows 10 裝置必須處於開發人員模式或是已安裝憑證。To run the app, the Windows 10 device must be in developer mode or already have the certificate installed.

若要部署到行動裝置,您必須先建立套件。To deploy to mobile devices, you must first create a package. 如需詳細資訊,請參閱此處For more information, see here.

Winappdeploycmd.exe .exe 工具位於 Windows 10 電腦上的這個位置:C:\Program Files (x86)\Windows Kits\10\bin\<SDK Version>\x86\WinAppDeployCmd.exe (根據 SDK 的安裝路徑)。The WinAppDeployCmd.exe tool is located here on your Windows 10 PC: C:\Program Files (x86)\Windows Kits\10\bin\<SDK Version>\x86\WinAppDeployCmd.exe (based on your installation path for the SDK).

注意

在 SDK 15063 和更新版本,SDK 是在版本特定的資料夾中並排安裝。In version 15063 and later of the SDK, the SDK is installed side by side within version-specific folders. 舊版 SDK (14393 之前版本) 會直接寫入上層資料夾。Previous SDKs (prior to and including 14393) are written directly to the parent folder.

首先,將您的 Windows 10 裝置連線到相同的子網路,或使用 USB 連線直接將它連線到您的 Windows 10 電腦。First, connect your Windows 10 device to the same subnet or connect it directly to your Windows 10 machine with a USB connection. 然後使用下列語法與本文稍後此命令的範例來部署您的 UWP App:Then use the following syntax and examples of this command later in this article to deploy your UWP app:

WinAppDeployCmd 語法和選項WinAppDeployCmd syntax and options

使用 WinAppDeployCmd.exe 的一般語法如下:This is the general syntax used for WinAppDeployCmd.exe:

WinAppDeployCmd command -option <argument>

以下是一些使用各種命令的其他語法範例︰Here are some additional syntax examples for using various commands:

WinAppDeployCmd devices
WinAppDeployCmd devices <x>
WinAppDeployCmd install -file <path> -ip <address>
WinAppDeployCmd install -file <path> -guid <address> -pin <p>
WinAppDeployCmd install -file <path> -ip <address> -dependency <a> <b> 
WinAppDeployCmd install -file <path> -guid <address> -dependency <a> <b>
WinAppDeployCmd uninstall -file <path>
WinAppDeployCmd uninstall -package <name>
WinAppDeployCmd update -file <path>
WinAppDeployCmd list -ip <address>
WinAppDeployCmd list -guid <address>
WinAppDeployCmd deployfiles -file <path> -remotedeploydir <remoterelativepath> -ip <address>
WinAppDeployCmd registerfiles -remotedeploydir <remoterelativepath> -ip <address>
WinAppDeployCmd addcreds -credserver <server> -credusername <username> -credpassword <password> -ip <address>
WinAppDeployCmd getcreds -credserver <server> -ip <address>
WinAppDeployCmd deletecreds -credserver <server> -ip <address>

您可以在目標裝置上安裝或解除安裝 app,或者您可以更新已經安裝的 app。You can install or uninstall an app on the target device, or you can update an app that's already installed. 若要保留已安裝的 app 儲存的資料或設定,請使用 update 選項,而不是 install 選項。To keep data or settings saved by an app that's already installed, use the update options instead of the install options.

下表描述 WinAppDeployCmd.exe 的命令。The following table describes the commands for WinAppDeployCmd.exe.

命令Command 描述Description
裝置devices 顯示可用網路裝置的清單。Show the list of available network devices.
installinstall 將 UWP 應用程式套件安裝到目標裝置。Install a UWP app package to the target device.
updateupdate 更新已經安裝在目標裝置的 UWP 應用程式。Update a UWP app that is already installed on the target device.
listlist 顯示已安裝在指定的目標裝置上的 UWP 應用程式清單。Show the list of UWP apps installed on the specified target device.
uninstalluninstall 從目標裝置解除安裝指定的 App 套件。Uninstall the specified app package from the target device.
deployfilesdeployfiles 將位於目標路徑的鬆散檔案 App 複製到遠端裝置上的相對路徑。Copy over loose file app at the target path to the remote relative path on the device.
registerfilesregisterfiles 在遠端部署目錄註冊鬆散檔案 App。Register the loose file app at the remote deploy directory.
addcredsaddcreds 將認證新增到 Xbox 以允許它存取 App 註冊的網路位置。Add credentials to an Xbox to allow it to access a network location for app registration.
getcredsgetcreds 取得目標從網路共用執行應用程式時所使用的網路認證。Get network credentials for the target uses when running an application from a network share.
deletecredsdeletecreds 刪除目標從網路共用執行應用程式時所使用的網路認證。Delete network credentials the target uses when running an application from a network share.

下表描述 WinAppDeployCmd.exe 的選項。The following table describes the options for WinAppDeployCmd.exe.

命令Command 描述Description
-h (-help)-h (-help) 顯示命令、選項和引數。Show the commands, options and arguments.
-ip-ip 目標裝置的 IP 位址IP address of the target device.
-g (-guid)-g (-guid) 目標裝置的唯一識別碼。Unique identifier of the target device.
-d (-dependency)-d (-dependency) (選擇性) 指定每個套件相依性的相依性路徑。(Optional) Specifies the dependency path for each of the package dependencies. 如果未指定路徑,工具會在應用程式套件和 SDK 目錄的根目錄中搜尋相依性。If no path is specified, the tool searches for dependencies in the root directory for the app package and the SDK directories.
-f (-file)-f (-file) 要安裝、更新或解除安裝的應用程式套件檔案路徑。File path for the app package to install, update or uninstall.
-p (-package)-p (-package) 要解除安裝的應用程式套件的完整套件名稱。The full package name for the app package to uninstall. (您可以使用清單命令來尋找已安裝在裝置上的套件完整名稱。)(You can use the list command to find the full names for packages already installed on the device)
-pin-pin 如果與目標裝置建立連線需要的 PIN。A pin if it is required to establish a connection with the target device. (如果需要驗證,系統會提示您使用 -pin 選項重試。)(You will be prompted to retry with the -pin option if authentication is required)
-credserver-credserver 目標使用之網路認證的伺服器名稱。The server name of the network credentials for use by the target.
-credusername-credusername 目標使用之網路認證的使用者名稱。The user name of the network credentials for use by the target.
-credpassword-credpassword 目標使用之網路認證的密碼。The password of the network credentials for use by the target.
-connecttimeout-connecttimeout 連線到裝置時的逾時 (以秒為單位)。The timeout in seconds used when connecting to the device.
-remotedeploydir-remotedeploydir 相對目錄路徑/名稱,檔案將複製到遠端裝置上的這個位置。這是已知且自動決定的遠端部署資料夾。Relative directory path/name to copy files over to on the remote device; This will be a well-known, automatically determined remote deployment folder.
-deleteextrafile-deleteextrafile 切換來指示是否要清除遠端目錄中的現有檔案以符合來源目錄。Switch to indicate whether existing files in the remote directory should be purged to match the source directory.

下表描述 WinAppDeployCmd.exe 的選項。The following table describes the options for WinAppDeployCmd.exe.

引數Argument 描述Description
<x><x> 逾時 (秒)。Timeout in seconds. (預設值為 10)(Default is 10)
<address><address> 目標裝置的 IP 位址或唯一識別碼。IP address or unique identifier of the target device.
<a><b> ...<a><b> ... 每個應用程式套件相依性的相依性路徑。Dependency path for each of the app package dependencies.
<p><p> 裝置設定中顯示用於建立連線的英數字元 PIN。An alpha-numeric pin shown in the device settings to establish a connection.
<path><path> 檔案系統路徑。File system path.
<name><name> 要解除安裝之應用程式套件的完整套件名稱。Full package name for the app package to uninstall.
<server><server> 檔案網路上的伺服器。Server on the file network.
<username><username> 具有檔案網路上伺服器存取權限之認證的使用者名稱。User for the credentials with access to the server on the file network.
<password><password> 具有檔案網路上伺服器存取權限之認證的密碼。Password for the credentials with access to the server on the files network.
<remotedeploydir><remotedeploydir> 裝置上相對於部署位置的目錄。Directory on device relative to the deployment location

WinAppDeployCmd.exe 範例WinAppDeployCmd.exe examples

以下列出一些有關如何從命令列使用 WinAppDeployCmd.exe 語法來部署的範例。Here are some examples of how to deploy from the command-line using the syntax for WinAppDeployCmd.exe.

顯示可供部署的裝置。Shows the devices that are available for deployment. 命令會在 3 秒後逾時。The command times out in 3 seconds.

WinAppDeployCmd devices 3

將您電腦上 Downloads 目錄下 MyApp.appx 套件中的應用程式安裝到 IP 位址 192.168.0.1 的 Windows 10 裝置,並使用 PIN 值 A1B2C3 與裝置建立連線。Installs the app from MyApp.appx package that is in your PC's Downloads directory to a Windows 10 device with an IP address of 192.168.0.1 with a PIN of A1B2C3 to establish a connection with the device

WinAppDeployCmd install -file "Downloads\MyApp.appx" -ip 192.168.0.1 -pin A1B2C3

從 IP 位址是 192.168.0.1 的 Windows 10 裝置解除安裝指定的套件 (根據其完整名稱)。Uninstalls the specified package (based on its full name) from a Windows 10 device with an IP address of 192.168.0.1. 您可以使用清單命令來查看安裝在裝置上任何套件的完整名稱。You can use the list command to see the full names of any packages that are installed on a device.

WinAppDeployCmd uninstall -package Company.MyApp_1.0.0.1_x64__qwertyuiop -ip 192.168.0.1

使用指定的應用程式套件,更新已安裝在 IP 位址 192.168.0.1 的Windows 10 裝置上的應用程式。Updates the app that is already installed on the Windows 10 device with an IP address of 192.168.0.1 using the specified app package.

WinAppDeployCmd update -file "Downloads\MyApp.appx" -ip 192.168.0.1

將 App 的檔案部署到 IP 位址為 192.168.0.1 的電腦或 Xbox 上;從和 AppxManifest 相同的資料夾,部署到該裝置部署路徑下的 app1_F5 目錄。Deploys the files of an app to a PC or Xbox with an IP address of 192.168.0.1 in the same folder as the AppxManifest to the app1_F5 directory under the deployment path of the device.

WinAppDeployCmd deployfiles -file "C:\apps\App1\AppxManifest.xml" -remotedeploydir app1_F5 -ip 192.168.0.1

在位於 192.168.0.1 的電腦或 Xbox 部署路徑下的 app1_F5 目錄註冊 App。Registers the app at the app1_F5 directory under the deployment path of the PC or Xbox at 192.168.0.1.

WinAppDeployCmd registerfiles -file app1_F5 -ip 192.168.0.1

使用 WinAppDeployCmd 在 Xbox One 上設定 [從電腦執行] 部署Using WinAppDeployCmd to set up Run from PC deployment on Xbox One

[從電腦執行] 可讓您將 UWP 應用程式部署到 Xbox One,且不複製其上的二進位檔,而是將二進位檔裝載於與 Xbox 相同網路中的網路共用上。Run from PC allows you to deploy a UWP application to an Xbox One without copying the binaries over, instead the binaries are hosted on a network share on the same network as the Xbox. 若要這樣做,您需要開發人員已解除鎖定的 Xbox One,以及 Xbox 可存取之網路磁碟機上的鬆散檔案 UWP 應用程式。In order to do this, you need a developer unlocked Xbox One, and a loose file UWP application on a network drive that the Xbox can access.

執行下列程式碼來註冊 App︰Run this to register the app:

WinAppDeployCmd registerfiles -ip <Xbox One IP> -remotedeploydir <location of app> -username <user for network> -password <password for user>

ex. WinAppDeployCmd register files -ip 192.168.0.1 -remotedeploydir \\driveA\myAppLocation -username admin -password A1B2C3