Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vb.net and writing cmd line output to listview

Posted on 2014-12-16
1
Medium Priority
?
321 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 35

Accepted Solution

by:
it_saige earned 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline
Suggested Courses

810 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