开发者

Process.Start - ( BEGINNER ) HELP

I have a .exe file written in C++. i have used;

Process.Start("E:\\cmdf.exe"); 

to execute the code from C#.

Now i need to:

  1. hide the command prompt
  2. Then to find a way to stop the command prompt (as in closing the application)
开发者_如何学运维

How do i do this?


To start without command window try this:

var exePath = @"E:\cmdf.exe";
var p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = exePath;
p.Start();

Then to end the process:

p.Kill();


See my answer here: How do I hide a console application user interface when using Process.Start?


To add to the other answers:

There is also the WindowStyle property which you can set to WindowStyle.Hidden.


This is the code to Hide the command prompt it works for me hope it will help you too.

  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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜