Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
Posted

1 solution

See this article on CP

Embedding a Console in a C# Application[^]
 
Share this answer
 
Comments
nareshkumar464 4-Oct-13 10:26am    
Can u please tell me how to execute the above command without creating the text file for multiple times?
Akinmade Bond 5-Oct-13 2:34am    
Have you read the article?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900