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

# Run

> IXtfRemoteRunClient::Run Method

# IXtfRemoteRunClient::Run Method

在主机上运行给定命令。

## 语法

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

### 参数

*pszCommandLine*\
类型：LPCWSTR

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

*pszWorkingDirectory*\
类型：LPCWSTR

远程主机上的工作目录。

*dwFlags*\
类型：DWORD

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

*dwPeriod*\
类型：DWORD

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

*pCallback*\
类型：[IXtfRemoteRunCallback \*](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md)

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

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

## 备注

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](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md) 同时包含输入和输出回调函数。无论你需要函数的输入*或*输出，还是需要函数的输入*和*输出，都可以填充其中一个或两个成员。

有关回调*输入*的详细信息，请参阅 [IXtfRemoteRunCallback::Input](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_input.md)。

有关回调*输出*的详细信息，请参阅 [IXtfRemoteRunCallback::Output](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_output.md)。

## 要求

**头文件：** xtfremoterun.h

**库：** xtfremoterun.lib

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

## 另请参阅

[XtfRemoteRun](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient.md)\
[IXtfRemoteRunClient](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient.md)\
[IXtfRemoteRunCallback](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md)


## Related topics

- [Run Task](https://docs.xbox.com/api-reference/scheduledtask/run-task.md)
- [XAsyncRun](https://docs.xbox.com/zh-CN/reference/system/xasync/functions/xasyncrun.md)
- [运行 (wdRun.exe)](https://docs.xbox.com/zh-CN/tools/tools-console/console_commandlinetools/wdrun.md)
- [XtfCreateRemoteRunClient](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/methods/xtfremoterun_xtfcreateremoterunclient.md)
- [XtfRemoteRun 成员（API 内容）](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfremoterun/xtfremoterun_members.md)
