Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb.net and writing cmd line output to listview

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 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