这是我以前写的一个小程序,可以驱动exe文件,你试试符合你的要求否?
using System.Diagnostics;
public string CmdPc(string cmdinput)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
try
{
p.Start();
p.StandardInput.WriteLine(cmdinput);
p.StandardInput.WriteLine("exit");
string ss = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
MessageBox.Show("OK");
return ss;
}
catch
{
string ss = "命令执行失败";
return ss;
}
}
string path = System.Windows.Forms.Application.StartupPath + \\MPlayer_all_setup.exe;
//string aa = CmdPc("C:\\MPlayer_all_setup.exe");//驱动文件的路径以及文件名
string aa = CmdPc(path);
MessageBox.Show(aa);