Link to home
Start Free TrialLog in
Avatar of centtech
centtech

asked on

Running DOS Commands C# (remove DOS Console)

Hi,
I'm writing a program in c# and i have made it so that i can run the DOS commands that require. The Only Problem i am having is that i cannot remove the black DOS Window that appears when the DOS Commands are run.

my current way of running the dos commands is as attached.


Thanks
Process mkdiraudio;
 
                mkdiraudio = Process.Start("cmd", @"/c ipconfig");
                mkdiraudio.WaitForExit();

Open in new window

Avatar of sirbounty
sirbounty
Flag of United States of America image

Use the ProcessStartInfo class
That way you can control whether the window is displayed or not.

See http://forums.msdn.microsoft.com/en-US/csharpgeneral/thread/6d217479-6e45-4e82-938e-97fc9c0a5ff3/
http://bytes.com/forum/thread365970.html

ProcessStartInfo psi = new ProcessStartInfo("cmd", @"/c ipconfig");
psi.WindowStyle = ProcessWindowStyle.Hidden;
Process mkdiraudio = Process.Start(psi);
mkdiraudio.WaitForExit();

Open in new window

Avatar of centtech
centtech

ASKER

kinda what i am looking for... the DOS Window still shows up.

i found this on another forum but cant get it to work ? any suggestions?

// The following commands are needed to redirect the standard output. This means that it will be redirected to the Process.StandardOutput StreamReader.
sinf.RedirectStandardOutput = true;
sinf.UseShellExecute = false;
// Do not create that ugly black window, please...
sinf.CreateNoWindow = true;

ASKER CERTIFIED SOLUTION
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial