show cmd window output and redirect to message box

I would like to see the output on the cmd window that popsup and then display it in a message box.  Currently it just pops up a cmd window thats blank and when the script is done it shows the output in the message box.  

Dim NVDLink As New Process
        Dim strRDomain As String = ""
        If RadioButton2.Checked = True Then
            strRDomain = "sw"
        ElseIf RadioButton1.Checked = True Then
            strRDomain = "ss"
        End If

        If ComboBox1.Text = "" Then
            MessageBox.Show("You must enter a NVDLink to search for", "Enter NVDLink", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If

        With NVDLink.StartInfo
            .CreateNoWindow = False
            .RedirectStandardOutput = True
            .RedirectStandardError = True
            .UseShellExecute = False
            .Arguments = "/c rsh toolsrv /scripts/nvdlink " & ComboBox1.Text & " " & strRDomain & " > c:\temp\nvdlink.txt"
            .FileName = "cmd.exe"
        End With
        Dim srNvdlink As New StreamReader("c:\temp\nvdlink.txt")
        Dim strNVD As String = ""
        While Not srNvdlink.EndOfStream()
            Dim line As String = srNvdlink.ReadLine

            If line <> "" Then

                If line <> "nothing returned" Then
                    strNVD += line & vbCrLf
                End If

            End If

        End While
        MessageBox.Show(strNVD, "NVDLink", MessageBoxButtons.OK, MessageBoxIcon.Information)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What I would do is to delete the output file redirection ( > c:\temp\nvdlink.txt)
and read the output stream to the end:

StreamReader theOutput = NVDLink.StandardOutput;
strNVD = theOutput.ReadToEnd();


I'm sorry about the syntax, byt in C# the thing works for me
I forgot the start

StreamReader theOutput = NVDLink.StandardOutput

Dim strNVD As String = ""
strNVD = theOutput.ReadToEnd()


Open in new window

chadmanvbAuthor Commented:
That does not seem to work.  I still see the cmd window popup, but dont see the output being displayed to the window.  
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

I am re-reading your post, and maybe I misunderstood you. You want both the windows cmd popup showing the results, and after that show the result output in a string to do whatever with it. Is that right?

In that case, I'm sorry to make you lose your time with my previous post.
Please let me know if at the end of the process the variable strNVD  is empty.

Your current application, is a windows form application or a console application?
chadmanvbAuthor Commented:
This is a form application.  My goal was to have the user just see the output on the cmd window while the script was running.  I was going to use this kind of like a progress bar, but it would let the user also see the output while they are waiting.  I do get the correct info on the strNVD.
The problem is that if you want to do something with the output data, something like parsing, you need to redirect, and it means that the console output window will show nothing.

I can only foresee two alternatives:

1. You can use a Text control and add the lines to it. Put the control properties to show a black background and white text as a console.  

2. You can create another Console window and rewrite the output to it from the variable strNVD or the strNVD variable itself.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chadmanvbAuthor Commented:
Thanks!  I thought about that, but just put a progress bar instead.  Thanks again for all of the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.