Solved

vb.net and writing cmd line output to listview

Posted on 2014-12-16
1
274 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

805 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