> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IXtfRemoteRunClient::Run Method

> IXtfRemoteRunClient::Run Method

# IXtfRemoteRunClient::Run Method

在主机上运行给定命令。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
public:
HRESULT Run(
         LPCWSTR pszCommandLine,
         LPCWSTR pszWorkingDirectory,
         DWORD dwFlags,
         DWORD dwPeriod,
         IXtfRemoteRunCallback *pCallback
)  
```

<a id="ID4EG" />

<a id="parametersSection" />

### 参数

*pszCommandLine*\
类型：LPCWSTR

要在远程主机上执行的命令行。

*pszWorkingDirectory*\
类型：LPCWSTR

远程主机上的工作目录。

*dwFlags*\
类型：DWORD

“备注”中描述的一个或多个标志。

*dwPeriod*\
类型：DWORD

重定向输出时，输出将被批处理并定期发送回客户端。此值指定批处理操作之间的毫秒数。

*pCallback*\
类型：[IXtfRemoteRunCallback \*](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback)

在重定向标准输入或输出时使用的回调。

<a id="ID4EP" />

<a id="retvalSection" />

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

<a id="remarks" />

## 备注

dwFlags 参数是以下任何值的按位与：

| 标志值                      | 效果                                                |
| ------------------------ | ------------------------------------------------- |
| XTFRUN\_WAIT             | 等待命令完成。默认行为是运行命令并立即返回，无需等待完成。                     |
| XTFRUN\_GUEST\_USER      | 在来宾用户帐户下运行。默认行为是以提升的系统用户身份运行。                     |
| XTFRUN\_REDIRECT\_INPUT  | 通过给定的 pCallback 重定向标准输入。这意味着 XTFRUN\_WAIT。        |
| XTFRUN\_REDIRECT\_OUTPUT | 通过给定的 pCallback 重定向标准输出。这意味着 XTFRUN\_WAIT。        |
| XTFRUN\_REDIRECT\_BOTH   | 通过给定的 pCallback 同时重定向标准输入和标准输出。这意味着 XTFRUN\_WAIT。 |

[IXtfRemoteRunCallback](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback) 同时包含输入和输出回调函数。无论你需要函数的输入*或*输出，还是需要函数的输入*和*输出，都可以填充其中一个或两个成员。

有关回调*输入*的详细信息，请参阅 [IXtfRemoteRunCallback::Input](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_input)。

有关回调*输出*的详细信息，请参阅 [IXtfRemoteRunCallback::Output](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_output)。

<a id="requirements" />

## 要求

**头文件：** xtfremoterun.h

**库：** xtfremoterun.lib

**支持的平台：** Windows（用于 XBOX 主机工具）

## 另请参阅

[XtfRemoteRun](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient)\
[IXtfRemoteRunClient](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient)\
[IXtfRemoteRunCallback](/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback)


## Related topics

- [IXtfRemoteRunClient Interface](/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient.md)
- [XtfCreateRemoteRunClient Method](/zh-CN/reference/tools/xtf/xtfremoterun/methods/xtfremoterun_xtfcreateremoterunclient.md)
- [IXtfRemoteRunCallback::Input Method](/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_input.md)
- [IXtfRemoteRunCallback::Output Method](/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_output.md)
- [IXtfRemoteRunCallback Interface](/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md)
