views:

79

answers:

1

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?

+1  A: 
If command.Contains("-q") Then
....
Else
Shell("cmd /k" & Command, 1, True)
End If
DaMartyr
Shell doesn't have a valid method like that did you miss something.
msarchet
DaMartyr
What namespace is shell in?
msarchet
Check out http://msdn.microsoft.com/en-us/library/0xca6kdd(v=VS.71).aspxI'm using 3.5 and don't have to add any special imports statement or references to get it to work.
DaMartyr