Invoking MS DOS applications
http://www.csharpfriends.com
World's Greatest C# Community    
Home Articles C# Forums Books C# Syntax C# Spec C# Jobs free Source Code Advertise About
 

Control Panel

[ Sign In / register ]
Points   
Notes 
My Forums
My Tutorials
My Profile

Resources

Learn
 Articles
 QuickStarts
 C# Spec
 Whitepapers
 Tools
 Class Browser
 C# Code Generator
 Links
 Misc Rss Feeds
 Code Highlight
 411 Directory
 FREE magazines
 freevb.net

Reviews
  ASP.NET Hosting

Source Code
 Get Version 1.0



C# Consulting
AspDotNetStoreFront
Chapter:   UnCategorized
Current Lesson:
Invoking MS DOS applications
[Latest Content]
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
[prev. Lesson]  A Matter Of Context [next Lesson]  User Controls in .NET (Part 1)
Invoking MS DOS applications
  by: joec

Invoking MS DOS applications

by: joec

This C# code uses System.Diagnostics.Process to invoke any MS DOS application and captures the

result back as a string for display or further processing. Below I invoke "ping" with an argument of

www.yahoo.com and then capture the results and invoke the MessageBox class to display the

results as an example of this code in action:

// #you will need the other usual using statements besides this one.
using System.Diagnostics; 

// #start a new process
Process p = new Process(); 

// #tells operating system not to use a shell;
p.StartInfo.UseShellExecute = false;        

//#need this false to capture results in stdout

//#allow me to capture stdout, i.e. results
p.StartInfo.RedirectStandardOutput = true; 

//#my command arguments, i.e. what site to ping
p.StartInfo.Arguments="www.yahoo.com"; 

//#the command to invoke under MSDOS
p.StartInfo.FileName=@"c:\ping";              

//#do not show MSDOS window
p.StartInfo.CreateNoWindow=true;            

//#do it!
p.Start();                                                 


//#capture results
string output = p.StandardOutput.ReadToEnd(); 

//#wait for all results.
p.WaitForExit();                                       


//#show results.
MessageBox.Show(output.ToString(),"result"); 

 
On my computer, here is what you can learn more about it - your link may be

the same or different.

ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdiagnosticsprocessmemberstopic.htm

If you have any questions you can email me at (joec_49@hotmail.com).


1 


Build Your Own ASP.NET Website Using C# & VB.NET

Chapter:  UnCategorized
Current Lesson:
Invoking MS DOS applications
[Latest Content]
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
[prev. Lesson]  A Matter Of Context [next Lesson]  User Controls in .NET (Part 1)


Today's Top Movers
vulpes 6800
MadHatter 2220
jal 867
Jeff1203 857
muster 791

Yesterday Top Movers
shakti sin.. 9
MadHatter 3
Al_Pennywo.. 2
C#fanatic 2
snaso 1

Monthly Leaders
vulpes 6800
MadHatter 2260
jal 867
Jeff1203 857
muster 791

Top Members
mosessaur 18457
Rincewind 7074
stanleytan 6995
vulpes 6800
Gsuttie 6046

Great Offers
.net hosting
Go To My Pc
Remote Pc Control
zonealarm
spam blocker
web hosting directory
ad server   C#
snadtech GoToMyPc

Top of Page

Advertise | About | Link To Us | Privacy Notice Copyright © 2003 - 2005 CSharpFriends.com  All Rights Reserved  Visual C# Developer Center