I'm currently in the process of creating a console application that acts as a Video Management Hub. I'm having issues with passing arguments into command line through process. Every time it returns the output from stdout and stderror using appropriate threads for each it's acting as though the Standard.Error.ReadToEnd() and Standard.Out.ReadToEnd() aren't seeing the full arguments after it's waited for the process to exit. Exception returns "is not recognized as an internal or external command, operable program or batch file." Code snippets below show Open method process.
private void Thread_ReadStandardError()
{
if (activeProcess != null)
{
stdErr = activeProcess.StandardError.ReadToEnd();
}
}
private void Thread_ReadStandardOut()
{
if (activeProcess != null)
{
stdOut = activeProcess.StandardOutput.ReadToEnd();
}
}
private string Open(string cmd)
{
string args = "/C [command]";
string temp_path = args.Replace("[command]",cmd);
this.pStartInfo.FileName = "cmd.exe";
this.pStartInfo.Arguments = "\"" + temp_path + "\"";
this.activeProcess.StartInfo = pStartInfo;
this.pStartInfo.CreateNoWindow = true;
this.pStartInfo.UseShellExecute = false;
this.pStartInfo.RedirectStandardOutput = true;
this.pStartInfo.RedirectStandardError = true;
activeProcess = Process.Start(pStartInfo);
Thread thread_ReadStandardError = new Thread(new ThreadStart(Thread_ReadStandardError));
Thread thread_ReadStandardOut = new Thread(new ThreadStart(Thread_ReadStandardOut));
if (pStartInfo.RedirectStandardError)
{
thread_ReadStandardError.Start();
}
if (pStartInfo.RedirectStandardOutput)
{
thread_ReadStandardOut.Start();
}
activeProcess.WaitForExit();
thread_ReadStandardError.Join();
thread_ReadStandardOut.Join();
string output = stdOut + stdErr;
return output;
}
Ultimately I am trying to use a modified version of ExifToolWrapper to run command line arguments to read in video Metadata. I got appropriate arguments/paths prior to my 'Open' method and handle white space before passing in arguments. Process is relatively new to me and prior I was trying to use EnvironmentalVariables to pass in arguments and I get the same output from stdOut+stdErr of
"C:Users###....is not recognized as an internal or external command..."
Is it possibly the way in which my process in setup?