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

> IXtfRemoteRunClient::Run 方法

# IXtfRemoteRunClient::Run 方法

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

<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 \*](/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback)

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

<a id="ID4EP" />

<a id="retvalSection" />

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

<a id="remarks" />

## 備註

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

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

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

<a id="requirements" />

## 需求

**標頭：** xtfremoterun.h

**程式庫：** xtfremoterun.lib

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

## 另請參閱

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


## Related topics

- [IXtfRemoteRunClient 介面](/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunClient/interfaces/ixtfremoterunclient.md)
- [XtfCreateRemoteRunClient 方法](/zh-TW/reference/tools/xtf/xtfremoterun/methods/xtfremoterun_xtfcreateremoterunclient.md)
- [IXtfRemoteRunCallback::Input 方法](/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_input.md)
- [IXtfRemoteRunCallback::Output 方法](/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_output.md)
- [IXtfRemoteRunCallback 介面](/zh-TW/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md)
