Solved

Running DOS Commands C# (remove DOS Console)

Posted on 2008-06-24
4
4,318 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lot of troubles with windows 10 7 53
Hey!!!! 1 20
PerfMon Report Time Out 6 23
Problem to file 4 21
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

770 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