Solved

vb.net and writing cmd line output to listview

Posted on 2014-12-16
1
283 Views
Last Modified: 2015-01-13
I am attempting to output command prompt data to a listview, which works but im having a few issues.  The command prompt window never exits to load the data to the listview, i have to click X and then it closes and loads the info to the listview.  When it does load it to listview, it doesnt separate the info out into 2 separate columns which i have created in the listview properties:


Dim psi As New ProcessStartInfo("cmd.exe")
        psi.Arguments = String.Concat(" /K systeminfo /S ", Form1.TextBox1.Text)
        psi.RedirectStandardOutput = True
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.UseShellExecute = False


        Dim pExec As New Process()
        pExec = Process.Start(psi)

        Dim output As StreamReader = pExec.StandardOutput
        pExec.WaitForExit()

        If pExec.HasExited Then
            Dim line As String
            Do
                line = output.ReadLine()
                If Not line Is Nothing Then
                    ListView1.Items.Add(line)
                End If
            Loop Until line Is Nothing
            output.Close()
        End If

Open in new window

0
Comment
Question by:derek7467
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 40503626
It's because you are not parsing the line into it's separate components.  To the listview a string is just a string, but a complex class is something entirely different.

Secondly, the process window is doing what you are telling it to do, start a new process and wait for the process window to close (not wait till the process itself has finished).

-saige-
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question