Groups | Blog | Home
all groups > c# > june 2007 >

c# : supress command prompt


YIguchi
6/19/2007 10:04:01 PM
Hi ,

I want to run a batch file from the c# code. Every time i run the batch file
command prompt is displayed. I do not want to show this command prompt.

Is there any way to suppress the command prompt.


Regards,
Tom Spink
6/20/2007 12:00:00 AM
[quoted text, click to view]

Hi,

Yes, try this:

///
using System.Diagnostics;

ProcessStartInfo pi = new ProcessStartInfo("batch.bat");
pi.UseShellExecute = false;

Process proc = new Process();
proc.StartInfo = pi;
proc.Start();
///

--
Tom Spink
Pete Kane
6/20/2007 12:00:00 AM
[quoted text, click to view]

The previous replies were almost correct, to completely hide the Dos window you need a combination of both the previous replies

ProcessStartInfo pi = new ProcessStartInfo("batch.bat");
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process proc = new Process();
proc.StartInfo = pi;
proc.Start();

Michael A. Covington
6/20/2007 1:48:44 AM
I'm not 100% sure what you're looking for, but try including the line

@prompt $g

as the first line of the .bat file. That will change the command prompt to
just ">".




[quoted text, click to view]

PS
6/20/2007 2:03:56 AM

[quoted text, click to view]

Do you want to hide the "DOS window" completely? You do this using
ProcessWindowStyle.Hidden for the value of the WindowsStyle property in
ProcessStartInfo.

PS
[quoted text, click to view]

AddThis Social Bookmark Button