0

I´m debuging an execution of a process:

public static bool ExecuteApplication(string executablePath, string arguments, bool wait, int waitingTime)
{
    bool success = false;
    if (CommonFiles.Exists(executablePath)) 
    {
        Process application = new Process();
        application.StartInfo.FileName = Path.Combine(executablePath);
        application.StartInfo.Arguments = arguments;
        application.StartInfo.WorkingDirectory = GetExpertPath();
        application.Start();
        if (wait) 
        {
            if (!application.WaitForExit(waitingTime)) 
            {
                application.Kill();
            }
            else 
            {
                success = true;
            }
        }
    }
    return success;
}

The code goes to application.Start() but doesn't go to next line. The process starts and ends well but my code is blocked. Before this code, there are more process executions.

Testing only this code runs ok.

Using application.StartInfo.UseShellExecute = false; the code goes to next step too.

Any idea?

Julien Roncaglia
  • 17,397
  • 4
  • 57
  • 75
  • What do you combine when you do Path.Combine(executablePath);? – Mo Patel Apr 09 '14 at 15:02
  • To resolve executable path if the path is relative. – Alvaro Miguelez Apr 09 '14 at 15:18
  • Are u sure your process ends well? Have u checked in the task manager's process list? – o_weisman Apr 10 '14 at 07:50
  • The process ends well. I have done another simple process (a empty window form aplication), the window appears and then i close it. The process starts and ends well but code doesn't go on. – Alvaro Miguelez Apr 10 '14 at 07:54
  • @AlvaroMiguelez What process are you starting? This guy had the same problem when trying to print word documents: http://stackoverflow.com/questions/3207417/process-start-with-useshellexecute-true-doesnt-return-for-corrupt-word-docu – o_weisman Apr 10 '14 at 12:45
  • Any process is blocked in Start line. I have done some applications and the code is blocked in the same line with all applications. The code doesn't detect process start neither process end. I have probed EnableRaisingEvents with Exited event and the code is not reached. – Alvaro Miguelez Apr 11 '14 at 06:26
  • @AlvaroMiguelez FYI if you want me to respond faster, you should start comments addressed to me with "@o_weisman" . Are you sure it is blocked and that it hasn't just thrown an exception? In addition, working directory is treated differently when UseShellExecute is false or true, see here: http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.processstartinfo.useshellexecute – o_weisman Apr 13 '14 at 13:58
  • @o_weisman in my case, FileName is full (with path) so WorkingDirectory is not important. The system doesn't throw any exception because the system is waiting to finish Start code line. The system doesn't detect process starts neither process ends. – Alvaro Miguelez Apr 14 '14 at 07:43
  • @AlvaroMiguelez There is another possibility: http://stackoverflow.com/questions/5702340/process-start-is-blocking-hanging-randomly-on-some-clients – o_weisman Apr 15 '14 at 08:24

0 Answers0