Specify command for the CMD to open

2

I am doing a simple program with Visual Studio to execute some commands in CMD that I want, currently the program has only a simple screen and a button to open the cmd, but I would like to specify the command that the prompt should run.

Eg: Ipconfig, flushdns, etc.

Currently my code is like this, using System.Diagnostics

namespace Comands 
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("CMD.exe");
        }
    }
}
    
asked by anonymous 25.07.2017 / 18:51

1 answer

2

You can use the same command with one more parameter:

System.Diagnostics.Process.Start( @"cmd.exe", @"/k c:\app.exe" );

For more details follow an English link I found: link

    
25.07.2017 / 19:16