Login Register


[C#] Running cmd Commands via Application filter_list
Author
Message
[C#] Running cmd Commands via Application #1
Hello there today I will show you how to run cmd commands such as /ipconfig in c#

Let's get started [Image: smile.png]

Code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace cmd {   public partial class Form1 : Form   {             public Form1()       {           InitializeComponent();       }       private void button1_Click(object sender, EventArgs e)       {                     System.Diagnostics.Process process = new System.Diagnostics.Process();           System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();                               startInfo.FileName = "cmd.exe";           startInfo.Arguments = "/ipconfig"; //Replace ipconfig with any command you may want :P           process.StartInfo = startInfo;           process.Start();                 }   } }
If you have any questions PM me or post below.

Reply

RE: [C#] Running cmd Commands via Application #2
Very nice! However, this is why I like C++, you can replace all of the above code with a simple line:
Code:
system("ipconfig")

Reply

RE: [C#] Running cmd Commands via Application #3
(06-09-2015, 05:11 PM)Prime02 Wrote: Very nice! However, this is why I like C++, you can replace all of the above code with a simple line:
Code:
system("ipconfig")

Nobody said you had to use the Process class in .NET (the VisualBasic dll contains Shell(): https://msdn.microsoft.com/en-us/library...90%29.aspx), but the equivalent of Process.Start() in C++ is much more complex. Also, system() is not a good idea.
- mostly braindead monkeys on this forum.

Reply







Users browsing this thread: 1 Guest(s)