.Net Process keep command window open

Posted by msarchet on Stack Overflow See other posts from Stack Overflow or by msarchet
Published on 2010-06-18T02:15:34Z Indexed on 2010/06/18 2:23 UTC
Read the original article Hit count: 366

Filed under:
|

right now I am working on a tool that does a lot of work via the Process object through the command line. So there are times when I want the command window to not show up and times when I want it to stay open so that the user can see what happened, possibly respond with the appropriate input.

 Dim pro As New Process
        pro.StartInfo.WorkingDirectory = path
        pro.StartInfo.Arguments = command
        pro.StartInfo.FileName = "hg"

        pro.StartInfo.RedirectStandardOutput = True
        If command.Contains("-q") Then
            pro.StartInfo.UseShellExecute = False
            pro.StartInfo.CreateNoWindow = True
            pro.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        End If

        pro.Start()

        pro.WaitForExit()

        Return pro.StandardOutput.ReadToEnd

The flag that I am checking in the command is for a -q if it doesn't contain this I would like to show the command prompt to the user and wait for them to close it.

Is this possible and if so what am I missing?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about command-line