Is anyone familiar with the CreateProc function and wsl in Windows? I’m trying to launch a Linux executable using wsl and it’s not working. I’m able to call a Windows .exe without any issue, but if I create a command with wsl as the prefix and a command, it’s not executing. Here’s the simple function that works (Notepad starts properly):
void USystemFunctionLibrary::ExecuteWSLCommand()
{
FString Command = TEXT(“C:\Windows\System32\notepad.exe”);
FProcHandle ProcHandle = FPlatformProcess::CreateProc(Command, TEXT(“”), true, false, false, nullptr, 0, nullptr, nullptr);
if (ProcHandle.IsValid())
{
UE_LOG(LogTemp, Log, TEXT("Successfully launched Notepad."));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to launch Notepad."));
}
}
But this doesn’t work:
void USystemFunctionLibrary::ExecuteWSLCommand()
{
FString Command = TEXT(“wsl ls”);
FProcHandle ProcHandle = FPlatformProcess::CreateProc(Command, TEXT(“”), true, false, false, nullptr, 0, nullptr, nullptr);
if (ProcHandle.IsValid())
{
UE_LOG(LogTemp, Log, TEXT("Successfully launched wsl"));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Failed to launch wsl"));
}
}
If I type the command in a CMD window (e.g. wls ls), it works, and also if I put C:\Windows\System32\notepad.exe, so the system PATH variables seems to be OK. Also, if I put wsl only as the command, it opens the wsl window with the path from where it’s called. But if I put anything else after wsl (e.g. ls as a test, or a path to an executable, then the ProcHandle isn’t valid).
Anyone familiar with launching Linux commands (or executables) from Unreal using wsl and CreateProc and that would know what the issue could be?
Thanks!