2

So this is my current code:

 private void StartButton_Click(object sender, EventArgs e)
    {
        Download = "placeholdercommand"

        string CWD = System.IO.Directory.GetCurrentDirectory();        

        Process process = new Process();
        ProcessStartInfo startInfo = new ProcessStartInfo();

        startInfo.Verb = "runas";                           ///launch as admin
        startInfo.FileName = "cmd.exe";                     ///launch cmd
        startInfo.Arguments = "/k cd /d " + CWD + "&" +     ///navigate cmd to CWD (/k = return)
                              Download + "&" +              ///give Download order to cmd
                              "exit";                       ///exit cmd

        process.StartInfo = startInfo;
        process.Start();
    }

Now I would like to make the cmd window invisible and display the cmd workings in real time in my c# window. How would I do this?

ManoDestra
  • 6,325
  • 6
  • 26
  • 50

1 Answers1

0

Use this to hide

info.WindowStyle=ProcessWindowStyle.Hidden;

Get the output

while (!process.StandardOutput.EndOfStream)
{
    string Line = process.StandardOutput.ReadLine();
}
mohsen
  • 1,763
  • 3
  • 17
  • 55