[Mono-list] How to Start Concatenated Processes by Using System.Diagnostics.Process?

Robert Jordan robertj at gmx.net
Fri Jun 18 05:29:15 EDT 2010


On 18.06.2010 11:13, Jacek Rużyczka wrote:
> Am Donnerstag 17 Juni 2010 16:25:04 schrieb Robert Jordan:
>> This. Or pass the commands to a shell process (untested):
>>
>> ProcessStartInfo info = new ProcessStartInfo();
>> info.UseShellExecute = false;
>> info.FileName = "/bin/bash";
>> info.Arguments = "-c 'pdflatex -interaction=nonstopmode receipt_60.tex
>> &&  gpg ... '";
>>
>> Note the quoting of the string for the -c option and latex
>> -interaction switch.
>>
> OK, thanks. The bash solution, I'm afraid, will not work for me as my app will
> also run on Windows, and I can hardly require my Windows users to install
> MinGW.
>
> But reagrding the solution with the two Process objects I've got a question.
> Normally, Process.Start() returns true once a process has been started
> successfully. However, I can only start gpg when pdflatex has successfully
> completed (!) its work.

The return value of Start() has a totally different (and useless)
meaning (see MSDN), so you better don't use it at all.

Process p = ...
p.Start();
p.WaitForExit();
if (p.ExitCode == 0) {  // success
   // start next process
}

Robert



More information about the Mono-list mailing list