I’m trying to perform an ImageMagick operation on some images I’m exporting from the engine. I’ve written a .bat file to do this, but I can also achieve the same result through a commandline operation so either would be a soution.
I’ve tried using FPlatformProcess::CreateProc to run the .bat itself but this seems to do nothing. I’ve also been through many different iterations trying to get CreateProc to open a cmd window to then run the relevant commands, I have more luck with the second, as I see the cmd window open for a split second but it instantly closes (I’ve provided a write and read pipe). Is there something I’m doing wrong? I’ve also looked into using system() and ShellExecute but to no avail,does anyone have any alternate solutions?
Here’s the code I’m using at the moment.
FString cmdPath = "C:\\Windows\\System32\\cmd.exe";
FString cmdParams = "cmd /k \"cd C:\\Users\\Admin\\Pictures && magick *T_* out.pdf\"";
//readPipe and writePipe are void* declared at class level
FPlatformProcess::CreatePipe(readPipe, writePipe);
cmdProcHandle = FPlatformProcess::CreateProc(*cmdPath, *cmdParams, true, false, false, &processIDPtr, 0, nullptr, writePipe, readPipe);
if (!cmdProcHandle.IsValid())
{
ensure(false);
}