Solved

Running DOS Commands C# (remove DOS Console)

Posted on 2008-06-24
4
4,325 Views
Last Modified: 2008-06-30
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

0
Comment
Question by:centtech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 21861981
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
0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21862036

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

Open in new window

0
 
LVL 1

Author Comment

by:centtech
ID: 21862080
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;

0
 
LVL 18

Accepted Solution

by:
philipjonathan earned 50 total points
ID: 21862266
Have you tried to insert those lines to the code above?
Can insert after line 2:
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;

Open in new window

0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question