# How to run Stat Startfile console command in C++?

**URL:** <https://forums.unrealengine.com/t/how-to-run-stat-startfile-console-command-in-c/433831>\
**Category:** C++\
**Tags:** console-commands, stat-system, unreal-engine, UE4, CPP, question\
**Created:** [September 14, 2018, 11:50pm UTC](https://forums.unrealengine.com/t/how-to-run-stat-startfile-console-command-in-c/433831 "2018-09-14T23:50:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yli327](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yli327](https://forums.unrealengine.com/u/Yli327)\
**Post date:** [September 14, 2018, 11:50pm UTC](https://forums.unrealengine.com/t/how-to-run-stat-startfile-console-command-in-c/433831/1 "2018-09-14T23:50:13Z")

</div>

Hey, guys

I want to call the console command Stat Startfile from c++. However, when I use ` FString startfile = "STAT STARTFILE"; GetWorld()->Exec(GetWorld(), *startfile);`, the engine is crashed.  
Could you guys please teach me how to run the command like Stat Start/StopFile in the C++?

Thanks  
Bests  
YL

---

<div class="post-metadata">

**Author:** ![Pelogetan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pelogetan](https://forums.unrealengine.com/u/Pelogetan)\
**Post date:** [November 29, 2021, 9:39am UTC](https://forums.unrealengine.com/t/how-to-run-stat-startfile-console-command-in-c/433831/3 "2021-11-29T09:39:01Z")

</div>

You need use player controller:  
Example in Character:

```
APlayerController* PC = GetPlayerController(this);
if(PC)
{
    PC->ConsoleCommand(TEXT("stat startfile"), true);
}
```
