代码之家  ›  专栏  ›  技术社区  ›  Schlinger

过程Start使用UseShellExecute false和RedirectStandardOutput创建窗口

  •  1
  • Schlinger  · 技术社区  · 10 年前

    所以我有个问题 Process.Start 始终显示窗口,即使我有属性 CreateNoWindow = true , UseShellExecute = false RedirectStandardOuput = true 。在所有的教程和网站上,他们都说这是一种方法。那么我在这里错过了什么?

    public static void StartExporter(string part, string path)
    {
        var startInfo = new ProcessStartInfo();
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.CreateNoWindow = true;
        startInfo.Verb = "runas";
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.FileName = "cmd.exe";
        startInfo.Arguments = "/k PartInfoExporter " + part + " " + path;
        var process = Process.Start(startInfo);
        process.WaitForExit();
    }
    

    谢谢你的帮助

    1 回复  |  直到 10 年前
        1
  •  0
  •   simon at rcl    10 年前

    方式命令。exe的工作非常复杂(根据Raymond Chen的说法,它实际上是一个VM)。为什么不跳过它,并调用PartInfoExporter。exe直接执行?