Title: WP_CLI::run_command()
Published: June 12, 2025
Last modified: April 13, 2026

---

# WP_CLI::run_command()

## In this article

 * [Usage](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#usage)
 * [Notes](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#notes)
 * [Related](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#related)

[↑ Back to top](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#wp--skip-link--target)

Run a given command within the current process using the same global parameters.

---

## 󠀁[Usage](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#usage)󠁿

    ```
    WP_CLI::run_command( $args, $assoc_args = [] )
    ```

 **$args** (array) Positional arguments including command name.
 **$assoc_args**(
array)

---

## 󠀁[Notes](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#notes)󠁿

Use `WP_CLI::runcommand()` instead, which is easier to use and works better.

To run a command using a new process with the same global parameters,
 use WP_CLI::
launch_self(). To run a command using a new process with different global parameters,
use WP_CLI::launch().

    ```
    ob_start();
    WP_CLI::run_command( array( 'cli', 'cmd-dump' ) );
    $ret = ob_get_clean();
    ```

_Internal APIAPI An API or Application Programming Interface is a software intermediary
that allows programs to interact with each other and share data in limited, clearly
defined ways. documentation is generated from the WP-CLIWP-CLI WP-CLI is the Command
Line Interface for WordPress, used to do administrative and development tasks in
a programmatic way. The project page is [http://wp-cli.org/](http://wp-cli.org/)
[https://make.wordpress.org/cli/](https://make.wordpress.org/cli/) codebase on every
release. To suggest improvements, please submit a pull request._

---

## 󠀁[Related](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-run-command/?output_format=md#related)󠁿

 * **[WP_CLI::launch()](https://make.wordpress.org/cli/handbook/internal-api/wp-cli-launch/)**–
   Launch an arbitrary external process that takes over I/O.
 * **[WP_CLI::launch_self()](https://make.wordpress.org/cli/handbook/internal-api/wp-cli-launch-self/)**–
   Run a WP-CLI command in a new process reusing the current runtime arguments.
 * **[WP_CLI::runcommand()](https://make.wordpress.org/cli/handbook/internal-api/wp-cli-runcommand/)**–
   Run a WP-CLI command.

First published

June 12, 2025

Last updated

April 13, 2026

Edit article

[ Improve it on GitHub: [article_title] ](https://github.com/wp-cli/handbook/edit/main/internal-api/wp-cli-run-command.md)

Changelog

[ See list of changes: [article_title] ](https://github.com/wp-cli/handbook/commits/main/internal-api/wp-cli-run-command.md)

[  Previous: WP_CLI::runcommand()](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-runcommand/)

[  Next: WP_CLI::success()](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-success/)