<small id='prVmn'></small><noframes id='prVmn'>

      <bdo id='prVmn'></bdo><ul id='prVmn'></ul>

  1. <tfoot id='prVmn'></tfoot>

    1. <legend id='prVmn'><style id='prVmn'><dir id='prVmn'><q id='prVmn'></q></dir></style></legend>
    2. <i id='prVmn'><tr id='prVmn'><dt id='prVmn'><q id='prVmn'><span id='prVmn'><b id='prVmn'><form id='prVmn'><ins id='prVmn'></ins><ul id='prVmn'></ul><sub id='prVmn'></sub></form><legend id='prVmn'></legend><bdo id='prVmn'><pre id='prVmn'><center id='prVmn'></center></pre></bdo></b><th id='prVmn'></th></span></q></dt></tr></i><div id='prVmn'><tfoot id='prVmn'></tfoot><dl id='prVmn'><fieldset id='prVmn'></fieldset></dl></div>
    3. C#:以隐藏方式运行外部控制台程序

      时间:2023-08-27

          <tfoot id='geUpB'></tfoot>
            <tbody id='geUpB'></tbody>
          <i id='geUpB'><tr id='geUpB'><dt id='geUpB'><q id='geUpB'><span id='geUpB'><b id='geUpB'><form id='geUpB'><ins id='geUpB'></ins><ul id='geUpB'></ul><sub id='geUpB'></sub></form><legend id='geUpB'></legend><bdo id='geUpB'><pre id='geUpB'><center id='geUpB'></center></pre></bdo></b><th id='geUpB'></th></span></q></dt></tr></i><div id='geUpB'><tfoot id='geUpB'></tfoot><dl id='geUpB'><fieldset id='geUpB'></fieldset></dl></div>
        1. <small id='geUpB'></small><noframes id='geUpB'>

            <bdo id='geUpB'></bdo><ul id='geUpB'></ul>

                <legend id='geUpB'><style id='geUpB'><dir id='geUpB'><q id='geUpB'></q></dir></style></legend>
                本文介绍了C#:以隐藏方式运行外部控制台程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                谁能告诉我如何从 Winforms 应用程序生成另一个控制台应用程序,但是 (A) 不在屏幕上显示控制台窗口,并且 (B) 仍然获得应用程序的标准输出?目前我有以下内容:

                 Process SomeProgram = new Process();SomeProgram.StartInfo.FileName = @"c:foo.exe";SomeProgram.StartInfo.Arguments = "bar";SomeProgram.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;SomeProgram.StartInfo.UseShellExecute = false;SomeProgram.StartInfo.RedirectStandardOutput = true;SomeProgram.Start();SomeProgram.WaitForExit();字符串 SomeProgramOutput = SomeProgram.StandardOutput.ReadToEnd();

                如果我将 RedirectStandardOutput 设置为 false,则控制台应用程序会按预期隐藏,但我无法获取标准输出文本.但是,只要我将 RedirectStandardOutput 设置为 true,窗口就会停止隐藏,尽管我能够获得程序的输出.

                所以,我知道如何使控制台应用程序隐藏运行,并且我知道如何获取程序的输出,但我如何让它同时实现这两者呢?

                许多 TIA

                解决方案

                您缺少 CreateNoWindow 属性,在您的情况下该属性必须设置为 true.p>

                can anyone tell me how to spawn another console application from a Winforms app, but (A) not show the console window on the screen, and (B) still obtain the standard output of the application? Currently I have something like the following:

                  Process SomeProgram = new Process();
                  SomeProgram.StartInfo.FileName = @"c:foo.exe";
                  SomeProgram.StartInfo.Arguments = "bar";
                  SomeProgram.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                  SomeProgram.StartInfo.UseShellExecute = false;
                  SomeProgram.StartInfo.RedirectStandardOutput = true;
                  SomeProgram.Start();
                  SomeProgram.WaitForExit();
                  string SomeProgramOutput = SomeProgram.StandardOutput.ReadToEnd();
                

                If I set RedirectStandardOutput to false, then the console app is hidden as expected, but I cannot get the standard output text. However, as soon as I set the RedirectStandardOutput to true, the window stops being hidden, although I am able to get the program's output.

                So, I know how to make the console app run hidden, and I know how to get the program's output, but how do I get it to do both?

                Many TIA

                解决方案

                You are missing the CreateNoWindow property which has to be set to true in your case.

                这篇关于C#:以隐藏方式运行外部控制台程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 .NET 中禁止将按键打印到控制台? 下一篇:重定向 cmd.exe 的输入和输出

                相关文章

                最新文章

                <legend id='5j9gm'><style id='5j9gm'><dir id='5j9gm'><q id='5j9gm'></q></dir></style></legend>
              • <small id='5j9gm'></small><noframes id='5j9gm'>

                <tfoot id='5j9gm'></tfoot>

                1. <i id='5j9gm'><tr id='5j9gm'><dt id='5j9gm'><q id='5j9gm'><span id='5j9gm'><b id='5j9gm'><form id='5j9gm'><ins id='5j9gm'></ins><ul id='5j9gm'></ul><sub id='5j9gm'></sub></form><legend id='5j9gm'></legend><bdo id='5j9gm'><pre id='5j9gm'><center id='5j9gm'></center></pre></bdo></b><th id='5j9gm'></th></span></q></dt></tr></i><div id='5j9gm'><tfoot id='5j9gm'></tfoot><dl id='5j9gm'><fieldset id='5j9gm'></fieldset></dl></div>

                    <bdo id='5j9gm'></bdo><ul id='5j9gm'></ul>