# Execute console command from a plugin

**URL:** <https://forums.unrealengine.com/t/execute-console-command-from-a-plugin/427627>\
**Category:** Plugins\
**Tags:** console-commands, unreal-engine, Plugins, Blueprint, CPP, question, execute-command\
**Created:** [June 18, 2018, 12:36pm UTC](https://forums.unrealengine.com/t/execute-console-command-from-a-plugin/427627 "2018-06-18T12:36:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shot511](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shot511](https://forums.unrealengine.com/u/Shot511)\
**Post date:** [June 18, 2018, 12:36pm UTC](https://forums.unrealengine.com/t/execute-console-command-from-a-plugin/427627/1 "2018-06-18T12:36:03Z")

</div>

Is there a way to execute console command directly from a plugin?

Currently I’m executing console command from the World Blueprint, but I want to move this functionality to the plugin.

---

<div class="post-metadata">

**Author:** ![Jawdy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jawdy](https://forums.unrealengine.com/u/Jawdy)\
**Post date:** [June 19, 2018, 1:44pm UTC](https://forums.unrealengine.com/t/execute-console-command-from-a-plugin/427627/2 "2018-06-19T13:44:22Z")

</div>

Firstly, be careful about relying on Console Execution - as most of the console (if not all) functionality gets stripped in Shipping builds! Also, writing C++ code that relies on console execution is preferred to be avoided, as per this [forum post](https://forums.unrealengine.com/development-discussion/c-gameplay-programming/4592-run-console-command-via-c).

Now, that said, and also from the Forum post (put here for ease/posterity), you can do it like so:

```
GetWorld()->Exec(GetWorld(), TEXT("MyAwesomeConsoleCommand X Y Z"));

```

That’s simply the Exec() function from the [UWorld](http://api.unrealengine.com/INT/API/Runtime/Engine/Engine/UWorld/) class. GetWorld() is a global getter for the current world. You might also want to check it’s valid before calling it, something like:

```
UWorld* World = GetWorld();

if( World != nullptr )
{
    World->Exec(GetWorld(), TEXT("MyAwesomeConsoleCommand X Y Z"));
}

```

---

<div class="post-metadata">

**Author:** ![Dan\_Hy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dan\_Hy](https://forums.unrealengine.com/u/Dan_Hy)\
**Post date:** [July 11, 2019, 1:43pm UTC](https://forums.unrealengine.com/t/execute-console-command-from-a-plugin/427627/3 "2019-07-11T13:43:58Z")

</div>

Hi.

Can you let me know what is the World and getWorld() in this fuction.

I am a new guy who wants to run blueprint node by C++ language.

Thank you so much.

---

<div class="post-metadata">

**Author:** ![Jawdy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jawdy](https://forums.unrealengine.com/u/Jawdy)\
**Post date:** [July 11, 2019, 2:23pm UTC](https://forums.unrealengine.com/t/execute-console-command-from-a-plugin/427627/4 "2019-07-11T14:23:52Z")

</div>

If you click on the UWorld link in the above post, it’ll take you to the documentation about that. And as for [GetWorld()](https://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AActor/GetWorld/index.html), it’s a function that every AActor has that will return the World that it is spawned within.
