Results 1 to 2 of 2

Thread: Line output form cmd

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2011
    Posts
    45

    Line output form cmd

    I am having an issue with naming buttons based on the line output. I can a message box to pop up with each line, however I would like to have each button named different lines of the output. Below is the code, any help would be appreciated.
    vb.net Code:
    1. Private Function nview_run() As Boolean
    2.         Dim nview_runProcess As New Process()
    3.         Dim nview_runStartInfo As New ProcessStartInfo()
    4.         nview_runStartInfo.FileName = "cmd.exe "
    5.         nview_runStartInfo.UseShellExecute = False
    6.         nview_runStartInfo.CreateNoWindow = True
    7.         nview_runStartInfo.Arguments = "/D /c net view"
    8.         nview_runStartInfo.RedirectStandardOutput = True
    9.         nview_runProcess.EnableRaisingEvents = True
    10.         nview_runProcess.StartInfo = nview_runStartInfo
    11.         nview_runProcess.Start()
    12.         Dim output As String
    13.         Dim readerStdOut As IO.StreamReader = nview_runProcess.StandardOutput
    14.         output = readerStdOut.ReadToEnd()
    15.         Dim lines() As String
    16.         Dim line As String
    17.         Dim pos As Integer
    18.         lines = output.Split(vbCrLf)
    19.         For Each line In lines
    20.             line = line.Trim
    21.             If line.StartsWith("\\") Then
    22.                 pos = line.IndexOf(" ")
    23.                 If pos > 0 Then
    24.                     line = line.Substring(0, pos)
    25.                 End If
    26.                 MessageBox.Show(line)
    27.             End If
    28.         Next
    29.     End Function

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Line output form cmd

    where do the buttons come into it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width