如何隐藏一个控制台应用程序用户界面使用的Process.Start什么时候? [英] How do I hide a console application user interface when using Process.Start?

查看:129
本文介绍了如何隐藏一个控制台应用程序用户界面使用的Process.Start什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个控制台应用程序,将输出文件。

我的用户以下code:

 过程barProcess =的Process.Start(bar.exe,@C:\ foo.txt的);
 

在此运行出现在控制台窗口。我想隐藏控制台窗口,所以它是没有看到用户。

这可能吗?使用的Process.Start最好的方式来启动另一个控制台应用程序?

解决方案

 进程p =新工艺();
        StreamReader的SR;
        StreamReader的本身;
        StreamWriter的SW;

        的ProcessStartInfo磅=新的ProcessStartInfo(@bar.exe);
        psi.UseShellExecute = FALSE;
        psi.RedirectStandardOutput = TRUE;
        psi.RedirectStandardError = TRUE;
        psi.RedirectStandardInput = TRUE;
        psi.CreateNoWindow = TRUE;
        p.StartInfo = PSI;
        p.Start();
 

这将启动一个子进程,而不显示控制台窗口,并允许StandardOutput等的拍摄

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");

When this runs the console window appears. I want to hide the console window so it is not seen by the user.

Is this possible? Is using Process.Start the best way to start another console application?

解决方案

        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.

这篇关于如何隐藏一个控制台应用程序用户界面使用的Process.Start什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆