我的程序只能在控制cmd.exe下用命令行运行,该程序的名称为convert.exe 而且还有3个参数需要传递给convert.exe,请问怎么实现。下面是我的代码,但不起作用。 string myAppPath = Application.StartupPath;
//this is exe file name
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = myAppPath + "\\OfficeConverter.exe" +" /m" +myAppPath+"\\mydoc.doc"+ myAppPath + "\\mydoc.docx"; //parameters
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
string strMsg = process.StandardOutput.ReadToEnd(); //exe output message.
process.Close();
谢谢大家先。
//this is exe file name
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = myAppPath + "\\OfficeConverter.exe" +" /m" +myAppPath+"\\mydoc.doc"+ myAppPath + "\\mydoc.docx"; //parameters
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
string strMsg = process.StandardOutput.ReadToEnd(); //exe output message.
process.Close();
谢谢大家先。
如:cmd.exe /k dir C:\
http://www.codeproject.com/cs/miscctrl/shellcontrol.asp
不用cmd的,直接把程序名指定为filename就可以了
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
process.StartInfo.Arguments = "/k" + myAppPath + "\\OfficeConverter.exe" +" /m" +myAppPath+"\\mydoc.doc"+ myAppPath + "\\mydoc.docx"; //parameters