我需要運行使用Process類從cmd窗口運行的舊應用程序。在CMD窗口中生成命令提示符應用程序的應用程序#
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C \"C:\\MySys\\My2Com.exe –r " + Parameters.FullPath;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch (Exception e)
{
string sMsg = "Error copying the files to " + Parameters.FullPath + ".";
HandleErrorMsg(e, sMsg);
return;
}
過程My2Com.exe應在後臺運行,但是,我consistantly得到一個文件,從不同的標誌CMD線運行時使用,郵件丟失。如果按照cmd窗口C:\ MySys \ My2Com.exe -r FullyQualPath中的指示運行該命令,則按預期工作。我嘗試了幾種不同的方式來設置Process類而沒有成功。
任何建議,將不勝感激。
謝謝。
你還沒有在你的Arguments屬性上加上一個雙引號。這是故意的嗎? – 2012-08-15 18:32:14