Executing a DOS type command from VB.NET and retrieving its ouput

  • Thread starter Thread starter James D. Marshall
  • Start date Start date
J

James D. Marshall

Please point me to some articles that explain how to execute a dos type
command and retrieve its output for processing.


Thanks.
 
James,

Here beneath a simple sample, however did you know that there was a special
newsgroup for VB.net language
microsoft.public.dotnet.languages.vb

\\\
Public sub myStart() as String
Dim p As New Process
dim pi as new processstartinfo
pi.UseShellExecute = False
pi.RedirectStandardOutput = True
pi.Arguments = myargumentstring
pi.WorkingDirectory = myworkdirectorystring
pi..FileName =C:\myprogram
pi.startinfo = pi
p.Start()
Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
Return SB.tostring
///

I hope this helps?

Cor
 
Thank you that does help a lot.
One question on parsing, the line has double carriage returns that show up
as squares, I am seeing this through watch1, how would you code a replace
statement to get rid of these, its driving me batty.
 
James,

Parsing can mean a lot in dotNet, so maybe better that you make a new
message, in this newsgroup or in the newsgroup I pointed you on. The last in
my idea better because VBNet has a lot of extra conversion functions which
make parsing easier. And as written by the VBNet development team better.

Cor
 
Back
Top