Monday, March 8, 2010

Run Command Line Apps and return output in C#

1784 private string runCommandTool(string strPathToTool, string strArguments)
1785 {
1786 string strReturn = ""; // Set up process
1787 System.Diagnostics.Process proc = new System.Diagnostics.Process();
1788 proc.StartInfo.UseShellExecute = false;
1789 proc.StartInfo.RedirectStandardOutput = true;
1790 proc.StartInfo.CreateNoWindow = true;
1791 proc.EnableRaisingEvents = false; // Run tool
1792 proc.StartInfo.FileName = "cmd.exe";
1793 proc.StartInfo.Arguments = " /C " + strPathToTool + " " + strArguments;
1794 proc.Start();
1795 proc.WaitForExit(); // Get output
1796 strReturn = proc.StandardOutput.ReadToEnd();
1797 return (strReturn);
1798 }

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...