# Run console command via C++?

**URL:** <https://forums.unrealengine.com/t/run-console-command-via-c/3942>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [May 7, 2014, 5:41pm UTC](https://forums.unrealengine.com/t/run-console-command-via-c/3942 "2014-05-07T17:41:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f355a76d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f355a76d](https://forums.unrealengine.com/u/anonymous_user_f355a76d)\
**Post date:** [May 7, 2014, 5:41pm UTC](https://forums.unrealengine.com/t/run-console-command-via-c/3942/1 "2014-05-07T17:41:11Z")

</div>

Simple question I hope - how do you run a console command from C++? Haven’t been able to find this so far, and the API pages are starting to not work.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8bc0661f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8bc0661f1](https://forums.unrealengine.com/u/anonymous_user_8bc0661f1)\
**Post date:** [May 7, 2014, 8:19pm UTC](https://forums.unrealengine.com/t/run-console-command-via-c/3942/2 "2014-05-07T20:19:55Z")

</div>

Though we generally try to avoid writing code that relies on executing console commands, you can do it with:

UWorld::Exec(…)

E.g,:

GetWorld()-\>Exec(GetWorld(), TEXT(“MyAwesomeConsoleCommand X Y Z”));

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f355a76d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f355a76d](https://forums.unrealengine.com/u/anonymous_user_f355a76d)\
**Post date:** [May 8, 2014, 8:23am UTC](https://forums.unrealengine.com/t/run-console-command-via-c/3942/3 "2014-05-08T08:23:06Z")

</div>

Awesome, thank you. Exactly what I needed.
