msarchet
msarchet

Reputation: 15232

.Net Process keep command window open

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?

Upvotes: 0

Views: 769

Answers (1)

NoAlias
NoAlias

Reputation: 9193

If command.Contains("-q") Then
....
Else
Shell("cmd /k" & Command, 1, True)
End If

Upvotes: 1

Related Questions