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

Run a given command on the console.

## Syntax

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

### Parameters

*pszCommandLine*\
Type: LPCWSTR

The command line to execute on the remote console.

*pszWorkingDirectory*\
Type: LPCWSTR

The working directory on the remote console.

*dwFlags*\
Type: DWORD

One or more of the flags described in Remarks.

*dwPeriod*\
Type: DWORD

When output is redirected, it is batched and sent back to the client periodically. This value specifies the number of milliseconds between batching operations.

*pCallback*\
Type: [IXtfRemoteRunCallback \*](https://docs.xbox.com/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md)

A callback used when standard input or output are redirected.

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

The dwFlags parameter is a bitwise-AND of any of the following values:

| Flag value | Effect |
| - | - |
| XTFRUN\_WAIT | Wait for the command to complete. Default behavior is to run the command and return immediately without waiting for completion. |
| XTFRUN\_GUEST\_USER | Run under the guest user account. Default behavior is to run as the elevated system user. |
| XTFRUN\_REDIRECT\_INPUT | Redirect standard input through the given pCallback. This implies XTFRUN\_WAIT. |
| XTFRUN\_REDIRECT\_OUTPUT | Redirect standard output through the given pCallback. This implies XTFRUN\_WAIT. |
| XTFRUN\_REDIRECT\_BOTH | Redirect both standard input and standard output through the given pCallback. This implies XTFRUN\_WAIT. |

The [IXtfRemoteRunCallback](https://docs.xbox.com/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/interfaces/ixtfremoteruncallback.md) contains both an input and an output callback function. You can populate either or both of these member whether you need input *or* output for a function or you need input *and* output for a function.

For more information about callback *input*, see [IXtfRemoteRunCallback::Input](https://docs.xbox.com/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_input.md).

For more information about callback *output*, see [IXtfRemoteRunCallback::Output](https://docs.xbox.com/reference/tools/xtf/xtfremoterun/classes/IXtfRemoteRunCallback/methods/ixtfremoteruncallback_output.md).

## Requirements

**Header:** xtfremoterun.h

**Library:** xtfremoterun.lib

**Supported platforms:** Windows (for XBOX console tools)

## See also

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


## Related topics

- [Run Task](https://docs.xbox.com/services/playfab/api-references/rest/admin/scheduled-task/run-task.md)
- [Run (wdRun.exe)](https://docs.xbox.com/tools/tools-console/console_commandlinetools/wdrun.md)
- [Run simple task](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
- [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md)
- [XtfCreateRemoteRunClient](https://docs.xbox.com/reference/tools/xtf/xtfremoterun/methods/xtfremoterun_xtfcreateremoterunclient.md)
