使用 WinAppDeployCmd.exe 工具安装应用Install apps with the WinAppDeployCmd.exe tool

Windows 应用程序部署 (WinAppDeployCmd.exe) 是一个命令行工具,可用于将通用 Windows 平台 (UWP) 应用从 Windows 10 电脑部署到任意 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. 你还可以将事先未打包的应用部署到远程电脑或 Xbox One。You can also deploy the app without packaging first to a remote PC or Xbox One. 本文介绍如何使用此工具安装 UWP 应用。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. 此命令不会安装应用所需的证书。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 工具位于 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).

备注

在 15063 版及更高版本的 SDK 中,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 应用: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>

你可以在目标设备上安装或卸载应用,也可以更新已经安装的应用。You can install or uninstall an app on the target device, or you can update an app that's already installed. 若要保留由已经安装的应用保存的数据或设置,请使用 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.
安装install 将 UWP 应用包安装到目标设备。Install a UWP app package to the target device.
更新update 更新已安装在目标设备上的 UWP 应用。Update a UWP app that is already installed on the target device.
列表list 显示已安装在指定目标设备上的 UWP 应用列表。Show the list of UWP apps installed on the specified target device.
卸载uninstall 从目标设备卸载指定的应用包。Uninstall the specified app package from the target device.
deployfilesdeployfiles 将目标路径处的松散文件应用复制到设备上的远程相对路径。Copy over loose file app at the target path to the remote relative path on the device.
registerfilesregisterfiles 将松散文件应用注册到远程部署目录。Register the loose file app at the remote deploy directory.
addcredsaddcreds 将凭据添加到 Xbox 以允许它访问应用注册的网络位置。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 与目标设备建立连接所需的引脚。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> 在设备设置中显示的用于建立连接的字母数字引脚。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

将应用从电脑的“下载”目录中的 MyApp.appx 程序包安装到 IP 地址为 192.168.0.1、PIN 为 A1B2C3 的 Windows 10 设备,以便与该设备建立连接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

将应用的文件部署到 IP 地址为 192.168.0.1 的电脑或 Xbox 中,这些文件与该设备的部署路径下的 app1_F5 目录中 AppxManifest 位于同一文件夹中。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

将应用注册在 IP 地址为 192.168.0.1 的电脑或 Xbox 的部署路径下的 app1_F5 目录。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.

运行此命令注册应用: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