Live Chat Icon For mobile
Live Chat Icon

How can I capture output from an arbitrary console application from within my Window Form application

Platform: WinForms| Category: Win32

Use the Process class found in the System.Diagnostic namespace.

	Process proc = new Process();
	
	// test.exe is a console application generated by VC6
	proc.StartInfo.FileName = @'C:\test\test.exe';

	proc.StartInfo.Arguments = '';
	proc.StartInfo.CreateNoWindow = true;
	proc.StartInfo.UseShellExecute = false;
	proc.StartInfo.RedirectStandardOutput = true;

	proc.Start();
	string output = proc.StandardOutput.ReadToEnd();

	//output now holds what text.exe would have displayed to the console

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.