0

I have an application that renders several chunks of video dynamically with data from a database and merge them all together at the end. Works good but some times the command line window wont close and that stops the whole process until I manually close it. I thought about placing a timer to force to close the window after some time in case it get stuck, but I guess is not the best way to do it.

Here is an example of the code that renders one of those chunks of video with the help of C#, command line and After Effects.

Process ProcessUnoRender;

ProcessSantaUnoRender = new ProcessStartInfo("cmd.exe", "/K aerender -project C:\\Santa\\temp\\insert1.aep & exit");
ProcessSantaUnoRender.CreateNoWindow = true;
ProcessSantaUnoRender.WindowStyle = ProcessWindowStyle.Normal;
ProcessSantaUnoRender.UseShellExecute = true;
ProcessSantaUnoRender.WorkingDirectory = @"C:\Santa\temp\";

ProcessUnoRender = Process.Start(ProcessSantaUnoRender);
ProcessUnoRender.WaitForExit();
ProcessUnoRender.Close();
fauvent
  • 107
  • 1
  • 13
  • 1
    Have you tried to use `/C` instead of `/K`? – Pavel Anikhouski Dec 12 '19 at 13:01
  • 1
    @PavelAnikhouski No, I haven't try that. Actually I am pretty much doing all this blindly because I am new to C#. Does /C prevent that to happen? I will search about that, thank you! – fauvent Dec 12 '19 at 13:03
  • `/C` means terminate after command execution, have a look at this [thread](https://stackoverflow.com/questions/515309/what-does-cmd-c-mean) – Pavel Anikhouski Dec 12 '19 at 13:11
  • I will try that and see how it works. Thanks @PavelAnikhouski – fauvent Dec 12 '19 at 13:13
  • 1
    Why do you start your program via CMD.Exe ? Is it a script or something ? Not an executable program ? The command line window is there for a user to type and read the output. You can just start your program directly `new ProcessStartInfo("aerender.exe", " -project ..` if there is an aerender.exe. If you use internal commands like "copy" or "dir" than you need to use cmd.exe. – Holger Dec 12 '19 at 14:03
  • Thanks for the answer @Holger. I am not sure why. I do what I can with the information I have. I didn't know that I could execute aerender.exe that way. I will try everything you guys suggest – fauvent Dec 12 '19 at 15:40

0 Answers0