Windows アプリケーションを起動するために、単純な C# 静的メソッドを使用しています。iexplore.exe を除くすべての 32 ビットまたは 64 ビット アプリケーションで正常に動作します。
私が電話するとき:
ExecHttp(@"C:\Program Files (x86)\Internet Explorer\iexplore.exe", "http://www.google.it");
System.Diagnostics.Process の WaitForExit() メソッドが iexplore.exe の終了を待機せず、ExitCode が exitcode=1 を返す。
ExecHttp は次のとおりです。
public static int ExecHttp(String strURL, String strArguments)
{
int intExitCode = 99;
try
{
Process objProcess = new System.Diagnostics.Process();
strArguments = "-nomerge " + strArguments;
System.Diagnostics.ProcessStartInfo psi = new ProcessStartInfo(strURL, strArguments);
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
psi.UseShellExecute = true;
objProcess.StartInfo = psi;
objProcess.Start();
Thread.Sleep(2000);
objProcess.WaitForExit();
intExitCode = objProcess.ExitCode;
objProcess.Close();
}
catch (Exception ex)
{
//log the exception
throw;
}
return intExitCode;
}
私は多くの検索を行いましたが、発見された唯一の回避策は、System.Diagnostic.Process.ProcessStartInfo Arguments プロパティに -nomerge キーワードを追加することです。WaitForExit() は、他の Windows .exe プロセスでは正常に機能しますが、iexplore.exe プロセスでは機能しません。iexplore.exe プロセスのプロセス ステータスをテストするにはどうすればよいでしょうか。
ありがとうございました