Windows App for macOS 提供了一个命令行界面(CLI),可用于执行各种任务作为用户界面的替代方法。 对于某些任务,使用 CLI 可以更高效,尤其是在需要多次执行同一任务或自动执行任务时。 在 macOS 上,使用内置的 终端 应用运行 CLI 命令。
本文介绍如何使用适用于 Windows 应用的 macOS CLI。
先决条件
在 macOS 上使用适用于 Windows 应用的 CLI 之前,需要安装适用于 macOS 的 Windows 应用。 有关详细信息,请参阅 Windows 应用入门以连接到设备和应用。
运行命令
若要使用适用于 Windows 应用的 CLI 运行命令,请执行以下操作:
在 macOS 设备上打开 终端 应用。
包含 Windows 应用可执行文件的默认路径是
/Applications/Windows App.app/Contents/MacOS
(区分大小写)。 运行以下命令以切换到此目录:cd '/Applications/Windows App.app/Contents/MacOS'
在此位置,可以使用不同的模块运行 Windows 应用可执行文件。 若要检查可以运行命令,请运行以下命令来打印帮助消息:
./'Windows App' --script
输出如下所示:
Usage: --script <module> <parameters> Modules: bookmark Create, edit or delete a connection bookmark. feed Subscribe to a resource feed, or edit or delete a subscription. gateway Create, edit or delete a Remote Desktop gateway. defaults Display client settings configurable through the defaults command To get help for a specific module: --script <module> help Examples: --script bookmark help --script feed help --script gateway help
可用模块列在上一命令的输出中。 可以通过添加模块名称(后跟
help
)来获取每个模块的完整语法,如上一步的输出所示。 例如,若要打印bookmark
模块的帮助信息,请运行以下命令:./'Windows App' --script bookmark help
输出如下所示:
Usage: --script bookmark <command> <unique ID> <parameter> Commands: write Create or edit a connection bookmark. delete Delete a connection bookmark. list List all stored bookmarks. export Output a bookmark as a formatted string. To get help for a specific command: --script bookmark <command> help Examples: --script bookmark write help --script bookmark delete help --script bookmark list help --script bookmark export help
最后,还可以遍历每个模块的每个命令,在命令名称后添加
help
来打印帮助信息,如上一步的输出中所示。
适用于每个模块和命令的 Windows 应用中提供的帮助信息提供了使用说明、参数详细信息以及如何使用每个命令的示例。
模块提示
以下提示可帮助你更有效地使用适用于 Windows 应用的 CLI:
对于需要唯一 ID 的命令,可以在
uuidgen
应用中运行该命令以生成唯一 ID。若要编辑保存的书签,请输入与用于创建书签的唯一 ID 相同的 ID。
write
命令使用新信息更新现有书签。对于
feed
模块,只能添加使用用户名和密码身份验证的远程桌面服务环境。 无法添加 Azure 虚拟桌面、Windows 365 或Microsoft Dev Box 资源,因为它使用基于声明的身份验证。