How do I use ProcessStartInfo to run a batch file?

十年热恋 提交于 2019-11-26 17:05:45

问题


But it doesn't work -meaning the java code is not executed. Although the batch file runs fine when clicked in Windows explorer or when run in command line ..

Since this works fine when the batch file is a single DOS command, I think this is somehow related to the fact that the Java code needs ~20 minutes to run. I'm using the following code

var si = new ProcessStartInfo();
si.CreateNoWindow = true;
si.FileName = batchFileName;
si.UseShellExecute = false;
Process.Start(si);

What am I doing wrong?


回答1:


Set UseShellExecute to true, so it loads cmd.exe to run the batch file.



来源:https://stackoverflow.com/questions/2382683/how-do-i-use-processstartinfo-to-run-a-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!