> ## 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 方法

# IXtfRemoteRunClient::Run 方法

在主機上執行指定的命令。

## 語法

```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-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md)

重新導向標準輸入或輸出時使用的回呼。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

dwFlags 參數是下列任何值的位元 AND：

| 旗標值 | 效果 |
| - | - |
| 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-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md) 同時包含輸入和輸出回呼函式。無論您的函式需要輸入*或*輸出，還是需要輸入*和*輸出，您都可以填入其中一個或兩個成員。

如需回呼*輸入*的詳細資訊，請參閱 [IXtfRemoteRunCallback::Input](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_input.md)。

如需回呼*輸出*的詳細資訊，請參閱 [IXtfRemoteRunCallback::Output](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_output.md)。

## 需求

**標頭：** xtfremoterun.h

**程式庫：** xtfremoterun.lib

**支援的平台：** Windows (適用於 XBOX 主機工具)

## 另請參閱

[XtfRemoteRun](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient.md)\
[IXtfRemoteRunClient](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient.md)\
[IXtfRemoteRunCallback](https://docs.xbox.com/zh-TW/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-TW/reference/system/xasync/functions/xasyncrun.md)
- [執行 (wdRun.exe)](https://docs.xbox.com/zh-TW/tools/tools-console/console_commandlinetools/wdrun.md)
- [XtfCreateRemoteRunClient](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfremoterun/methods/xtfremoterun_xtfcreateremoterunclient.md)
- [XtfRemoteRun 成員 (API 內容)](https://docs.xbox.com/zh-TW/reference/tools/xtf/xtfremoterun/xtfremoterun_members.md)
