我正在执行命令提示符命令,如下所示:
string cmd = "/c dir" ;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = cmd;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
Run Code Online (Sandbox Code Playgroud)
如何获取命令的输出?
我试图从.NET程序调用php-cgi.exe.我使用RedirectStandardOutput将输出作为流返回,但整个过程非常慢.
你对我如何能加快速度有任何想法吗?还有其他技术吗?
Dim oCGI As ProcessStartInfo = New ProcessStartInfo()
oCGI.WorkingDirectory = "C:\Program Files\Application\php"
oCGI.FileName = "php-cgi.exe"
oCGI.RedirectStandardOutput = True
oCGI.RedirectStandardInput = True
oCGI.UseShellExecute = False
oCGI.CreateNoWindow = True
Dim oProcess As Process = New Process()
oProcess.StartInfo = oCGI
oProcess.Start()
oProcess.StandardOutput.ReadToEnd()
Run Code Online (Sandbox Code Playgroud)