Home
Manage Your Code
Snippet: Execute application with arguments (C#)
Title: Execute application with arguments Language: C#
Description: Execute application with arguments Views: 131
Author: astle lara Date Added: 8/27/2008
Copy Code  
1private void executeApplication( string appName, string args )
2{
3System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.Process.Start( appName , args );
4pInfo.RedirectStandardOutput = true;
5pInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden // if you don’t want to see the application execute;
6pInfo.UseShellExecute = false;
7
8System.Diagnostics.Process listFiles;
9listFiles = System.Diagnostics.Process.Start( pInfo );
10System.IO.StreamReader processOutput = listFiles.StandardOutput;
11processOutput.WaitForExit( 2000 );
12if ( listFiles.HasExited )
13{
14string processResults = processOutput.ReadToEnd();
15this.processResults.Text = processResults;
16}
17}