[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Running DOS Commands C# (remove DOS Console)

Posted on 2008-06-24
4
Medium Priority
?
4,330 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 200 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Configuring Remote Assistance for use with SCCM
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

656 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