How do i run a Console Command in C++

Hi, i saw this thread -> https://forums.unrealengine.com/showthread.php?4419-Run-console-command-via-C on how to run a console command via c++, but i want to do something like this.


 FString MyCommandString = "r.SetRes ";
 FString Resolution = "1920x1080";
 
 FString Final = MyCommandString + Resolution;
 
 GetWorld()->Exec(GetWorld(), TEXT(Final));

but i get horrible errors like ‘LFinal is undefined’ ? where does the ‘L’ come from? I can’t Execute a var string command :confused: it has to be direct like in the thread above. Any Ideas?

Edit: I’m currently using 4.7.6 but i’m sure i had this problem back in 4.6. also

Get rid of TEXT()

I get an error ‘no suitable conversion function from"FString" to “TCHAR*” exists’?

Hey, try this : GetWorld()->Exec(GetWorld(), *Final);

Yeah! that worked thanks :smiley: