0

I've been able to call a cmd process to run a batch file. It runs but I have no idea what it does bec' the window opens and closes too fast. I've used .WaitForExit(), but it doesn't help. I've been looking for more help and can find anything specific. I can't tell if my batch file runs or not and where the output redirects too. Any help would be greatly appreciated. Thanks.

Gabe

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by tostrinj
0

You remind me with graduation project days :)

public void GenerateKeyFile(string command)
        {
            ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe");
            PSI.RedirectStandardInput = true;
            PSI.RedirectStandardOutput = true;
            PSI.RedirectStandardError = true;
            PSI.UseShellExecute = false;
            Process p = Process.Start(PSI);
            System.IO.StreamWriter SW = p.StandardInput;
            System.IO.StreamReader SR = p.StandardOutput;
            SW.WriteLine(command);
            SW.Close();
        }
0

ok, quick and dirty, to be removed before building release - used to help me in my student years. Last line of code is :
Console.ReadLine();

that will wait until you kill the console.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.