3

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

1 Answer 1

5

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()
Sign up to request clarification or add additional context in comments.

2 Comments

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
I just got it: compiler.StartInfo.CreateNoWindow = True

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.