2

C# からコマンド ライン ユーティリティ PCLI.exe を実行しようとしていますが、うまくいきません。ProcessStartInfo オブジェクトを構築していて、process.StartInfo.RedirectStandardOutput = true を設定していますが、process.StandardOutput を読み込もうとすると、次のエラーが発生します。

Message=StandardOut has not been redirected or the process hasn't started yet.

コマンドの出力をoutput.txtにパイプするだけでも試しましたが、ファイルが作成されている間は空です。

プロセスは完了しますが、目的のファイルは実際には実行されないため、何が起こっているのかを確認するために StandardOutput をキャプチャしようとしています。バックグラウンドの目的で、PVCS get コマンドを実行して PVCS からファイルを取得しようとしています。

これが私のコードのスニペットです:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new     
System.Diagnostics.ProcessStartInfo();
process.StartInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.WorkingDirectory = "c:\\gitmover";
startInfo.FileName = "C:\\Program Files (x86)\\Serena\\vm\\win32\\bin\\pcli.exe";

Console.WriteLine("Password:?");
string password = Console.ReadLine();
for (int i = 0; i < revisionsArray.Count(); i++)
    {
       string fileName = "/" + file.Key.Substring(file.Key.IndexOf("Customers")).Replace('\\','/');
       startInfo.Arguments = "get -r" + revisionsArray[i] + " -id\"beng:" + password + "\" -prM:\\Engineering\\SOUP -o -ac:/gitmover -bp'/Customers' -z " + fileName + "> output.txt";
       process.StartInfo = startInfo;
       process.Start();
       string strOutput = process.StandardOutput.ReadToEnd();

       //Wait for process to finish
       process.WaitForExit();
    }
4

2 に答える 2