如何使用的ProcessStartInfo运行批处理文件? [英] How do I use ProcessStartInfo to run a batch file?

查看:399
本文介绍了如何使用的ProcessStartInfo运行批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

但它不工作,意思是不执行的Java code。
虽然在Windows资源管理器点击或在批处理文件运行正常,当在命令行中运行。

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 ..

由于当批处理文件是一个DOS命令这工作得很好,我认为这是某种联系的Java code需要约20分钟,运行的事实。
我用下面的code

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?

推荐答案

设置 UseShellExecute 来真的,所以它加载到CMD.EXE运行该批处理文件。

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

这篇关于如何使用的ProcessStartInfo运行批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆