It is extremely simple to create a mysqldump in cmd on home windows, simply:

Open cmd and set type mysqldump uroot ppassword database > c:/data.sql

This leads to an SQL dump apply for the preferred database.

I am writing a console application and so i might run this command:

-uroot -ppass databse  > location\data.sql

I attempted the next code with no success:

System.Diagnostics.ProcessStartInfo procStartInfo =
    new System.Diagnostics.ProcessStartInfo("cmd", "/c " + cmd); 

How might I begin a cmd process and send my command effectively?

Process cmd = new Process();

cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;


/* execute "dir" */


It is possible to reason you do not call mysqldump directly?

ProcessStartInfo procStartInfo = 
    new ProcessStartInfo("mysqldump", "uroot ppassword databse > c:/data.sql");

If there is grounds, your code need to look such as this:

ProcessStartInfo procStartInfo = 
    new ProcessStartInfo("cmd", 
        "/c \"mysqldump uroot ppassword databse > c:/data.sql\"");


  • You where missing "mysqldump" inside your cmd variable.
  • You need to place the command to become performed within the command line into quotes.

Would you run Process.Start(psi) using the ProcessStartInfo instance you've just produced?

Anyway, the next must do the job:

string commandToExecute = @"c:\windows\system32\calc.exe";
Process.Start(@"cmd", @"/c " + commandToExecute);