执行控制台命令并获取其输出 [英] Execute console command and get its output

查看:46
本文介绍了执行控制台命令并获取其输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在Visual Basic 2008中如何在不借助中间文件的情况下执行外部控制台(命令行)命令并获得其输出(以加快速度)?

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)?

推荐答案

看看 Process.StandardOutput .

示例:

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()

这篇关于执行控制台命令并获取其输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆