Solved

vb.net and writing cmd line output to listview

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

Accepted Solution

by:
it_saige earned 500 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now