最小化称为C#Processinfo的每个进程

时间:2011-06-28 04:36:38

标签: c#

假设我有这段代码:

        string strCmdText2 = @"/C connect.exe --connect 1.txt";
        ProcessStartInfo PSI = new ProcessStartInfo("CMD.exe", strCmdText2);
        PSI.CreateNoWindow = true;
        //PSI.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        PSI.RedirectStandardInput = true;
        PSI.RedirectStandardOutput = true;
        PSI.RedirectStandardError = true;
        PSI.UseShellExecute = false;
        Process p = Process.Start(PSI);

问题是,当执行这些语句时,connect.exe会打开它的窗口,我该如何隐藏它?喜欢在后台跑?

谢谢

1 个答案:

答案 0 :(得分:0)

您正在重定向标准输入。使用TextWriter将strCmdText2写入流程。

编辑:如果上述操作不起作用,请尝试以下操作:

    string strCmdText2 = @"--connect 1.txt";
    ProcessStartInfo PSI = new ProcessStartInfo("connect.exe", strCmdText2);
    PSI.CreateNoWindow = true;
    //PSI.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    PSI.RedirectStandardInput = true;
    PSI.RedirectStandardOutput = true;
    PSI.RedirectStandardError = true;
    PSI.UseShellExecute = false;
    Process p = Process.Start(PSI);