private void PerformJob() { textLog.Clear(); // Create directory ahead of time Directory.CreateDirectory(textOutput.Text); // Setup our config var configPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "unlinkmkv.ini"); var config = new Config(configPath); var merge = PathUtility.FindExePath("mkvmerge.exe"); var info = PathUtility.FindExePath("mkvinfo.exe"); var extract = PathUtility.FindExePath("mkvextract.exe"); var ffmpeg = ""; try { ffmpeg = PathUtility.FindExePath("ffmpeg.exe"); } catch (Exception e) { // Do nothing } config.OutputPath = textOutput.Text; config.SetRequiredPaths(ffmpeg, extract, info, merge); config.Persist(configPath); // TODO: Support the rest of the parameters as they become reasonable to support var files = Directory.GetFiles(textInput.Text); var perlParams = GetCommandLineArguments(); var perlPath = PathUtility.FindExePath("perl.exe"); var outDirectory = "--outdir \"" + textOutput.Text + "\""; var perlScript = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "winport.pl"); // For each file, we need to run the Perl script once. It doesn't support batch mode foreach (var file in files) { // Generate a Perl job var quotedFile = "\"" + file + "\""; var argument = "\"" + perlScript + "\" " + perlParams + " " + outDirectory + " " + quotedFile; // PathUtility.ExceptionalPath var startInfo = new ProcessStartInfo { FileName = perlPath, Arguments = argument, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }; string x = perlPath + " " + argument; ExecuteSecure(() => textLog.AppendText(CleanEscape(x) + Environment.NewLine)); // Add the path if required to the Perl executing path if (!string.IsNullOrEmpty(PathUtility.ExceptionalPath)) { startInfo.EnvironmentVariables["PATH"] = PathUtility.ExceptionalPath; } var perlJob = new Process() { StartInfo = startInfo }; perlJob.ErrorDataReceived += (s, e) => Console.WriteLine(e.Data); perlJob.Start(); _currProcess = perlJob; while (!perlJob.StandardOutput.EndOfStream) { string line = perlJob.StandardOutput.ReadLine(); ExecuteSecure(() => textLog.AppendText(CleanEscape(line) + Environment.NewLine)); } _currProcess.WaitForExit(); _currProcess = null; } // End the job ExecuteSecure(() => MessageBox.Show("The unlinking is complete!", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information)); buttonExecute.Enabled = true; buttonAbort.Enabled = false; }