How do I hide a console application user interface when using Process.Start?

后端 未结 4 1455
挽巷
挽巷 2021-02-14 19:59

I want to run a console application that will output a file.

I user the following code:

Process barProcess = Process.Start(\"bar.exe\", @\"C:\\foo.txt\")         


        
4条回答
  •  梦谈多话
    2021-02-14 20:50

            Process p = new Process();
            StreamReader sr;
            StreamReader se;
            StreamWriter sw;
    
            ProcessStartInfo psi = new ProcessStartInfo(@"bar.exe");
            psi.UseShellExecute = false;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError = true;
            psi.RedirectStandardInput = true;
            psi.CreateNoWindow = true;
            p.StartInfo = psi;
            p.Start();
    

    This will start a child process without displaying the console window, and will allow the capturing of the StandardOutput, etc.

提交回复
热议问题