ProcessStartInfo hanging on “WaitForExit”? Why?

前端 未结 22 1851
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 02:59

I have the following code:

info = new System.Diagnostics.ProcessStartInfo(\"TheProgram.exe\", String.Join(\" \", args));
info.CreateNoWindow = true;
info.Win         


        
22条回答
  •  伪装坚强ぢ
    2020-11-22 03:21

    I was having the same issue, but the reason was different. It would however happen under Windows 8, but not under Windows 7. The following line seems to have caused the problem.

    pProcess.StartInfo.UseShellExecute = False
    

    The solution was to NOT disable UseShellExecute. I now received a Shell popup window, which is unwanted, but much better than the program waiting for nothing particular to happen. So I added the following work-around for that:

    pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    

    Now the only thing bothering me is to why this is happening under Windows 8 in the first place.

提交回复
热议问题