i'm using a simple C# static method in order to launch windows application. All works fine with all 32 or 64 bit application except for iexplore.exe.
When i call:
ExecHttp(@"C:\Program Files (x86)\Internet Explorer\iexplore.exe", "http://www.google.it");
System.Diagnostics.Process WaitForExit() method does not wait for iexplore.exe closure and ExitCode get back exitcode=1.
Here is 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;
}
I've done a lot of search and the only workaround founded is to add -nomerge keyword on System.Diagnostic.Process.ProcessStartInfo Arguments property. WaitForExit() works fine on other windows .exe process but NOT with iexplore.exe process. How could we test the process status of iexplore.exe process?
Thank you