0
コンソールアプリケーションを使用してC#でシェルを作成しています。私のシェルを使って、cmdやbashのように、ping.exe、takeown.exeなどの他のアプリケーションを実行します。C#コンソール内で実行中の別のアプリケーションへのStreamWrite(Interact)アプリケーション
標準出力を他のプロセスからコンソールアプリケーションにリダイレクトする際に問題はありません。問題は、StardardInを正しくリダイレクトして、実行中のアプリケーションと対話できるようにする方法がわかりません。私は、 "y"を入力してcacls.exeを使ってアクションを確認する必要があると言います。ここで
はStandardOutのための私のコードです:
どのように私は戻ってアプリケーションに書き込むことができますか?
Process process = new Process();
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = cmd;
process.StartInfo.Arguments = Arguments;
process.OutputDataReceived += new DataReceivedEventHandler(
(s, e) =>
{
Console.WriteLine(e.Data);
}
);
process.ErrorDataReceived += new DataReceivedEventHandler((s, e) => { Console.WriteLine(e.Data); });
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
'process.StandardInput.WriteLine( "Y")を使用することができます;' –