从C#运行DOS命令行? [英] running dos command line from C#?

查看:450
本文介绍了从C#运行DOS命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行命令行提示符下面的命令:

I am trying to run this command from command-line prompt:

"D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless"

当我在命令行控制台输入它完美的作品。

It works perfect when I type it in a command-line console.

然而,当我试图让它从C#工作应用程序,它失败了。我试过以下,但似乎上面的命令没有得到执行莫名其妙:

However, when I was trying to make it work from C# application, it failed. I tried following, but seems the command above did not get executed somehow:

string fijiCmdText = "D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless";
System.Diagnostics.Process.Start("cmd.exe", fijiCmdText);



任何人有任何想法如何改变它的工作?谢谢你。

Anyone has any idea how to change it to work? Thanks.

推荐答案

确定。因为克里斯 - 哈斯不会回答这个问题,我必须这样做,因为这个问题解决了在他指明了方向。这并不意味着其他的答案不工作,它只是意味着问题可以至少以某种方式得到解决。

OK. since Chris Haas wouldn't answer this questions, I have to, because the problem was solved as in the direction he pointed out. It does not mean other answers don't work, it just means the problem can be solved at least in one way.

这是,简单地增加/ C中的代码,它应该工作:

Here it is, simply adding "/C " in the code, and it should work:

原件,没有工作:

string fijiCmdText = "D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless";
System.Diagnostics.Process.Start("cmd.exe", fijiCmdText)



;

目前的代码如下:

string fijiCmdText = "/C D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless";
System.Diagnostics.Process.Start("cmd.exe", fijiCmdText);



希望这有助于。同时也感谢大家,设法帮助,尤其阿林Ghazarian Sudhakar Tillapudi

下面是<一个HREF =htt​​p://stackoverflow.com/questions/5635020/simple-software-testing-tool-vb-net/5635703#5635703>引用由克里斯·哈斯提到。请参阅 EDIT3

这篇关于从C#运行DOS命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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