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:
- hide the command prompt
- 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();
精彩评论