Download

Open cmd.exe window in UE4 C++

Hello Community!

I’m having a hard time trying to get a command prompt window to open. I’ve tried the following:



void ATestCommander::BeginPlay()
{
Super::BeginPlay();

FProcHandle WorkHandle = FPlatformProcess::CreateProc(TEXT("C:\\Windows\\System32\\cmd.exe"), nullptr, true, false, false, nullptr, 0, nullptr, nullptr);

if (WorkHandle.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("I DID IT!"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("DANG!"));
}

}


and I’ve tried



// Called when the game starts or when spawned
void ATestCommander::BeginPlay()
{
Super::BeginPlay();


bool bWorked = FPlatformProcess::ExecProcess(TEXT("C:\\Windows\\System32\\cmd.exe"), nullptr, false, false, false);

if (bWorked)
{
UE_LOG(LogTemp, Warning, TEXT("I DID IT!"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("DANG!"));
}

}


Both of them do return true with their conditions. I’ve tried other applications and they indeed do open just fine. Just Command Prompt seems to not open at all through UE4.

Is there something I need to do to open the command prompt in Windows?

Bumping this up… Anyone know why the commandline in windows won’t pop up with these methods?

F’in Windows. :smiley: It might be some sort of context-running issue like Admin / Group-policy rights. :wink:
You didn’t say if ‘cmd.exe’ appears at all in Task-Mangler (hidden). That’s the first thing I’d check.
After that, test drive Rama’s Plugin to see if it works. And if it does, copy over *RamaSutra *code. :stuck_out_tongue: