Console Output

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
View Poll Results: Why No Example Given For real Time Console Redirect
Microsoft my not be interested 1 100.00%
It may be under Developement 0 0%
It is avaliable, But not aware 0 0%
No Idea 0 0%
Voters: 1. You may not vote on this poll

Reply

Join Date: Apr 2007
Posts: 3
Reputation: danasegarane is an unknown quantity at this point 
Solved Threads: 0
danasegarane danasegarane is offline Offline
Newbie Poster

Console Output

 
0
  #1
Sep 7th, 2007
Hi all,
I want to redirect the console output in real time to a textbox. And if any standard error arrives or Process completed than i have to give one msgbox stating that process completed.Is there any method avalible.Presently I have this code.But it is not working properly

  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Me.TextBox1.Text = String.Empty
  3. Dim clsProcess As New System.Diagnostics.Process()
  4. clsProcess.StartInfo.UseShellExecute = False
  5. clsProcess.StartInfo.RedirectStandardOutput = True
  6. clsProcess.StartInfo.RedirectStandardError = True
  7. clsProcess.StartInfo.FileName = "cmd dir/s"
  8. clsProcess.StartInfo.CreateNoWindow = True
  9. clsProcess.Start()
  10. While (clsProcess.HasExited = False)
  11. Dim sLine As String = clsProcess.StandardOutput.ReadLine
  12. If (Not String.IsNullOrEmpty(sLine)) Then
  13. Me.TextBox1.Text &= sLine & vbCrLf
  14. End If
  15. Application.DoEvents()
  16. End While
  17. Me.TextBox1.Text += "Completed"
  18. End Sub

Thanks in Advance
Dana
Last edited by danasegarane; Sep 7th, 2007 at 7:15 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1
Reputation: whenwephil is an unknown quantity at this point 
Solved Threads: 0
whenwephil whenwephil is offline Offline
Newbie Poster

Re: Console Output

 
0
  #2
Sep 13th, 2007
Hi

Your code is almost there. All that is required is to break apart the filename and add arguments. See below

p

Dim clsProcess As New System.Diagnostics.Process()
clsProcess.StartInfo.UseShellExecute = False
clsProcess.StartInfo.RedirectStandardOutput = True
clsProcess.StartInfo.RedirectStandardError = True
clsProcess.StartInfo.FileName = "cmd.exe"
clsProcess.StartInfo.Arguments = "dir /s"
clsProcess.StartInfo.CreateNoWindow = True
clsProcess.Start()
While (clsProcess.HasExited = False)
Dim sLine As String = clsProcess.StandardOutput.ReadLine
If (Not String.IsNullOrEmpty(sLine)) Then

End If
Me.TextBox1.Text &= sLine & vbCrLf

Application.DoEvents()
End While
Me.TextBox1.Text += "Completed"
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4799 | Replies: 1
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC