无法使用C#Process类运行交互式程序 [英] Not able to run interactive program using C# Process class

查看:49
本文介绍了无法使用C#Process类运行交互式程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,


基本问题是在同一个程序中读取stdin和stdout以下程序是我用线程编写的,但我发现stdout正在工作,但是当应用程序需要输入时它无法工作。


''myprog.pl''很简单请求你的名字和打印相同的perlscript。执行顺序如下:


c:\ myprog.pl

输入你的名字:Myname

你的名字是: Myname


当我从下面给出的C#prog运行这个脚本时,它根本不是要求输出名称而是提供以下输出;


C:\ myCSharpProg.exe

stdin

stdout

输入你的名字:你的名字是:


任何人都可以帮助我,如果有任何替代方法可以实现这一点,对我来说会非常有用。


感谢高级,
Megha


Hi Friends,

The basic issue is "To read stdin and stdout in the same program" The following program is i have wrote using thread but i figured out that stdout is working but it is not working when application need the input.

''myprog.pl'' is the simple perlscript which ask for the your name and print the same. the execution sequence is given below:

c:\ myprog.pl
Enter your name: Myname
Your name is: Myname

When i am running this script from my C# prog given below it it is not asking for the name at all and it is giving following output;

C:\myCSharpProg.exe
stdin
stdout
Enter your name:Your name is :

Could anyone please help me on this, it will be veryhelpful to me if any alternative method is there to achieve this.

Thanks in Advanced,
Megha


展开 | 选择 | Wrap | 行号

推荐答案

你做了很多奇怪的事情。


例如
You do a lot of wierd stuff.

For instance
展开 | 选择 | Wrap | 行号


谢谢你的回复。


但是我不能改变cmd.exe。因为我想要所有带扩展名的命令(.msc,.pl,.cpl,.exe等),这些命令可能不是win32应用程序,其中Process类在分配Process.File时无法生成进程。关于\ n我正在照顾。


谢谢,

Paresh
Thanks for the reply.

But i cant change "cmd.exe" because i wants to all the commands with extensions (.msc,.pl,.cpl,.exe etc) which may not be win32 application where Process class failed to spawn process when it assigned Process.File. About "\n" i am taking care.

Thanks,
Paresh


如果可以使用提供的参数运行CMD,提供的参数将作为进程自行运行。

通过使用带参数的CMD,您实际上只是重新包装应用程序。

它就像是一样你刚刚运行CMD

然后在CMD窗口中键入你的文件名。


唯一不能正常工作的是像dir这样的命令;,cd和其他特定于控制台的命令。
If CMD can be run with the arguments provided, the arguments provided will run by themselves as the processes.
By using CMD with arguments, you are effectively just re-wrapping the application.
It''s the same as if you just ran CMD
Then in the CMD window type your filename.

The only things that don''t work like that are commands like "dir", "cd" and other console specific commands.


这篇关于无法使用C#Process类运行交互式程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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