我这边有点没太理解你的意思,不过我按着我的理解给你写一个方法,你试试看:
public static string runCmd(string command)
{
string msg = "";
Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; //设定需要执行的命令
p.StartInfo.UseShellExecute = false; //不使用系统shell外壳程序启动
p.StartInfo.RedirectStandardInput = true; //重定向输入(一定是true)
p.StartInfo.RedirectStandardOutput = true; //重定向输出
p.StartInfo.RedirectStandardError = true;
//p.StartInfo.Arguments = command;
p.StartInfo.CreateNoWindow = true; //不创建窗口
try
{
if (p.Start())
{
p.StandardInput.WriteLine(command);
p.StandardInput.WriteLine("exit");
msg = p.StandardOutput.ReadToEnd();
p.Close();
}
else
msg = "DOS线程创建失败";
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
然后你把你的exe文件的全路径传进去,就相当于在黑框中运行你的exe程序,不知道是不是你要的效果。