问题描述
我有一组要在命令提示符下执行的行,例如
open venture.upload.akamai.com
abcdef
ghijklm
hash
binary
lcdD:\ testing
cd/ 26929 / Vinoth新QC文件夹/测试/测试/
提示
mgetEng Vs Aus 01-08-131_874.MP4
mgetEng Vs Aus 01-08-131_873.MP4
退出
目前,Iam创建文本文件并使用下面的代码在命令提示符下执行文件,现在我想在控制台中写入结果。
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo(cmd,/ c+ command);
procStartInfo.WorkingDirectory = Application.StartupPath +\\Temp;
procStartInfo.RedirectStandardInput = false;
procStartInfo.Redire ctStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start( );
string result = proc.StandardOutput.ReadToEnd();
Console.WriteLine(result);
Hi,
I have set of lines to be execute in command prompt,example
open venture.upload.akamai.com
abcdef
ghijklm
hash
binary
lcd "D:\testing"
cd "/26929/Vinoth New QC Folder/Testing/Test/"
prompt
mget "Eng Vs Aus 01-08-131_874.MP4"
mget "Eng Vs Aus 01-08-131_873.MP4"
quit
Currently,Iam creating text file and executing the file in command prompt using below code,now i want to write the result in console.
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
procStartInfo.WorkingDirectory = Application.StartupPath + "\\Temp";
procStartInfo.RedirectStandardInput = false;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
Console.WriteLine(result);
推荐答案
这篇关于在CommandPrompt中运行一组行并将结果写入控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!