Question : How to keep a process (command) window open

I have the code below.  My problem is that the command window closed immediately, and when I have a problem with the code below (i.e. gsec.exe is missing), I don't have a chance to read the error message.

How do I run this and keep the process window open?
1:
2:
3:
4:
5:
6:
System.Diagnostics.Process p = new System.Diagnostics.Process();
                    p.StartInfo.WorkingDirectory = firebirdInstallationPath;
                    p.StartInfo.FileName = "gsec.exe";
                    p.StartInfo.Arguments = "-add prager -pw books";
                    p.Start();
                    p.WaitForExit();

Answer : How to keep a process (command) window open

You can redirect the standard output of your command:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
static void Main(string[] args)
{
    System.Diagnostics.Process p = new System.Diagnostics.Process();
    p.StartInfo.WorkingDirectory = firebirdInstallationPath;
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = "gsec.exe";
    p.StartInfo.Arguments = "-add prager -pw books";
    p.Start();
    p.WaitForExit();

    string output = p.StandardOutput.ReadToEnd();
}
Random Solutions  
 
programming4us programming4us