The following code snippet can be used to run a command as if you are opening a DOS prompt and typing it in.
public static string MyDOSMethod()
{
ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
Process p = Process.Start(si);
p.StandardInput.WriteLine(@"cd \windows\system32");
p.StandardInput.WriteLine("exit");
try
{
return p.StandardOutput.ReadToEnd();
}
catch (Exception e)
{
return e.Message;
}
}