2

I think the C# process class has a problem with accepting < or > characters when they are passed as paramaters.

When I call the following code, the executable returns me an error indicating that I passed more than one argument.

 proc = new Process();
 proc.StartInfo.FileName = this.spumux.SpumuxExe;
 proc.StartInfo.Arguments = "menu.xml < menu.mpg > newmenu.mpg";
 proc.StartInfo.UseShellExecute = false;
 proc.StartInfo.CreateNoWindow = true;
 proc.StartInfo.RedirectStandardOutput = true;
 proc.StartInfo.RedirectStandardError = true;
 proc.EnableRaisingEvents = true;
 proc.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
 proc.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
 proc.Exited += new EventHandler(ProcExited);
 proc.Start();
 proc.BeginOutputReadLine();
 proc.BeginErrorReadLine();

This code normally worked with every other executable I tried so far without any problems. So it's gotta do something with <, > characters

Any ideas?

0

4 Answers 4

5

The angle brackets in this case mean redirecting the input/output, which is done by cmd.exe, not by the started process.

You have two options:

  • call cmd.exe instead of your executable, and supply the executable as an argument (and the arguments for your exe as well)
  • redirect standard input/output yourself.
Sign up to request clarification or add additional context in comments.

1 Comment

Ok but why? I am calling ffmpeg.exe just like that and it works with the arguments I supply. Why would I call cmd.exe now?
0

try "menu.xml \< menu.mpg \> newmenu.mpg". And you are adding 5 args. To make it one - do: "\"menu.xml \< menu.mpg \> newmenu.mpg\""

Comments

0

I'm not sure what your attempting to accomplish here. Are you trying to redirect IO with '<' and '>', or are you trying to pass these as arguments?

You can redirect IO by running CMD.exe with the /C option:

proc.StartInfo.FileName = @"C:\Windows\System32\Cmd.exe";
proc.StartInfo.Arguments = "/C \"" + this.spumux.SpumuxExe + " menu.xml < menu.mpg > newmenu.mpg\"";

1 Comment

I am only trying to pass arguments. And this code works fine with other executables with other types of arguments. It just does not seem to accept "<", ">"
0

I was only be able to solve this issue by creating a batch file, where I pass the arguments without "<", ">"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.