Skip to content

Instantly share code, notes, and snippets.

@monir-dev
Created December 27, 2018 07:30
Show Gist options
  • Save monir-dev/fced5684129e4839344c9241a4f6effd to your computer and use it in GitHub Desktop.
Save monir-dev/fced5684129e4839344c9241a4f6effd to your computer and use it in GitHub Desktop.
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine(@"cd 'C:\Users\Monir\Desktop\Exchange Script'");
cmd.StandardInput.WriteLine(@"dir");
cmd.StandardInput.WriteLine(@"cd E:\Projects\ASP.NET MVC'");
cmd.StandardInput.WriteLine(@"dir");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
//cmd.WaitForExit();
Console.WriteLine(cmd.StandardOutput.ReadToEnd());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment