1

How i can execute commands of cmd and return the values of this. For example, i execute the command Ipconfig and return a list of interface available

Thanks.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Claudio Riquelme
  • 33
  • 1
  • 2
  • 5

2 Answers2

4

This post has a great answer. It also shows how you can run commands without the command prompt popping up.

string strCmdText;
strCmdText= "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
periodic
  • 41
  • 4
1

You can use the Process.Start() method to run command-line commands, capture the console outputs, and parse it to get your return values. It's a bit messy but it works.

Philip Atz
  • 886
  • 1
  • 10
  • 26