0

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
  • 3,359
  • 4
  • 15
  • 26

2 Answers2

2

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
  • 21
  • 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
  • 883
  • 1
  • 10
  • 26