//process piping using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using System.IO; using System.Windows.Forms; namespace IndiLogiX.Propipe { static class IProcessPipe { public static void ExecPro(string ProcName, string args, string WrkDir, string cmdtxt, out string coutext) { Process cmd = new Process(); cmd.StartInfo.FileName = ProcName; cmd.StartInfo.Arguments = args; cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.WorkingDirectory = WrkDir; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.ErrorDialog = true; cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.RedirectStandardInput = true; cmd.StartInfo.RedirectStandardError = true; cmd.Start(); StreamWriter cin = cmd.StandardInput; StreamReader cout = cmd.StandardOutput; cin.WriteLine(cmdtxt); cin.Close(); coutext = cout.ReadToEnd(); cmd.WaitForExit(); cmd.Close(); } public static string ExecPro(string ProcName, string args, string WrkDir, string cmdtxt) { Process cmd = new Process(); string coutext; cmd.StartInfo.FileName = ProcName; cmd.StartInfo.Arguments = args; cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.WorkingDirectory = WrkDir; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.ErrorDialog = true; cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.RedirectStandardInput = true; cmd.StartInfo.RedirectStandardError = true; cmd.Start(); StreamWriter cin = cmd.StandardInput; StreamReader cout = cmd.StandardOutput; cin.WriteLine(cmdtxt); cin.Close(); coutext = cout.ReadToEnd(); cmd.WaitForExit(); cmd.Close(); return coutext; } } }