私が取り組んでいるアプリケーションでは、すべてがうまく機能します。私の質問は、psexec を実行するときにコマンド ウィンドウを抑制する方法はありますか? これは黙って走らせたい。以下は私が使用しているコードです。オンラインで多くの例を読みましたが、何も機能していないようです。考え?ありがとう。
Process p = new Process();
try
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p = Process.Start(psExec, psArguments);
if (p != null)
{
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
if (p != null)
{
p.Dispose();
}
}