// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; using System.IO; using System.Text; namespace E { public class Program { public static void Main(string[] args) { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "cmd"; psi.Arguments = @"/c dir C:\arne\*.bat /s"; psi.CreateNoWindow = true; psi.UseShellExecute = false; psi.RedirectStandardOutput = true; Process p = Process.Start(psi); StreamReader sr = p.StandardOutput; StringBuilder sb = new StringBuilder(); string line; while((line = sr.ReadLine()) != null) { sb.Append(line + "\r\n"); } sr.Close(); p.Close(); Console.WriteLine(sb.ToString()); } } }