Process クラスを使用してコマンド ウィンドウから実行されるレガシー アプリを実行する必要があります。
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 はバックグラウンドで実行する必要がありますが、さまざまなフラグを指定して cmd ラインから実行したときに使用されるファイルが見つからないというメッセージが常に表示されます。C:\MySys\My2Com.exe –r FullyQualPath というコマンド ウィンドウに示されているコマンドを実行すると、期待どおりに動作します。Process クラスをセットアップする方法をいくつか試しましたが、成功しませんでした。
任意の提案をいただければ幸いです。
ありがとうございました。