tags:

views:

53

answers:

1

I'm wondering, in Visual Basic 2008, how to execute an external dos command and get its output without help of an intermediate file (to speed up)?

+4  A: 

Have a look at ProcessStartInfo.RedirectStandardOutput and Process.StandardOutput.

Example:

compiler.StartInfo.FileName = "csc.exe"
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs"
compiler.StartInfo.UseShellExecute = False
compiler.StartInfo.RedirectStandardOutput = True
compiler.Start()

Console.WriteLine(compiler.StandardOutput.ReadToEnd())

compiler.WaitForExit()
dtb
Hi dtb,Thanks for your reply.I think it works well. The only thing is that it will pop up a command window till the external command ends. How can I suppress this window? Thanks
Peter Lee
I just got it:compiler.StartInfo.CreateNoWindow = True
Peter Lee