

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 安装适用于 Windows 的防护
<a name="setting-up-windows"></a>

你可以通过 Cargo 或 Ch AWS CloudFormation Guard ocolatey 在 Windows 上安装。

## 先决条件
<a name="w2aab8c16b5"></a>

要通过命令行界面构建 Guard，必须安装适用于 Visual Studio 2019 的构建工具。

1. 从 Visual [Studio 2019 版构建工具网站上下载微软 Visual](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) C\+\+ 构建工具。

1. 运行安装程序，然后选择默认值。

## 安装货物防护
<a name="install-guard-from-cargo"></a>

Cargo 是 Rust 包管理器。完成以下步骤来安装 Rust，其中包括 Cargo。然后，安装 Guard from Cargo。

1. [下载 Rust](https://forge.rust-lang.org/infra/other-installation-methods.html#other-ways-to-install-rustup) 然后运行 **rustup-init.exe**。

1. 在命令提示符下，选择 **1**，这是默认选项。

   该命令将返回以下输出。

   ```
   Rust is installed now. Great!
       
       To get started you may need to restart your current shell.
       This would reload its PATH environment variable to include
       Cargo's bin directory (%USERPROFILE%\.cargo\bin).
       
       Press the Enter key to continue.
   ```

1. 要完成安装，请按 E **nter** 键。

1. 安装了 Cargo 后，运行以下命令来安装 Guard。

   ```
   cargo install cfn-guard
   ```

   *结果*：你已经成功安装了 Guard。

   1. （可选）要确认 Guard 的安装，请运行以下命令。

     ```
     cfn-guard --version
     ```

     该命令将返回以下输出。

     ```
     cfn-guard 3.1.2
     ```

## 安装来自 Chocolatey 的守卫
<a name="install-guard-from-chocolatey"></a>

Chocolatey 是一款适用于 Windows 的软件包管理器。完成以下步骤安装 Chocolatey。然后，安装来自 Chocolatey 的 Guard。

1. 按照本指南[安装 Chocolat](https://chocolatey.org/install) ey

1. 安装了 Chocolatey 后，运行以下命令来安装 Guard。

   ```
   choco install cloudformation-guard
   ```

   *结果*：你已经成功安装了 Guard。

   1. （可选）要确认 Guard 的安装，请运行以下命令。

     ```
     cfn-guard --version
     ```

     该命令将返回以下输出。

     ```
     cfn-guard 3.1.2
     ```