简体   繁体   English

如何在C#上运行命令提示程序?

[英]How to run command prompt programs on C#?

I would like to know if there is a way to run a command prompt program such as "C:/temp/mactimes.pl" which the command "perl mactimes.pl" could be run in the C# program. 我想知道是否有办法运行命令提示程序,如“C:/temp/mactimes.pl”,命令“perl mactimes.pl”可以在C#程序中运行。

I have looked through "process.start" class but it only detects .exe format programs. 我查看了“process.start”类,但它只检测.exe格式程序。 Therefore I need the "perl" command to startup the perl script. 因此,我需要“perl”命令来启动perl脚本。

Please do give advices! 请提出建议! Thanks!!! 谢谢!!!

If perl is in the system PATH: 如果perl在系统路径中:

Process.Start("perl.exe", "C:\\temp\\mactimes.pl");

Otherwise you will need to enter the full path to it. 否则,您需要输入它的完整路径。

Try to use "cmd.exe" as the executable. 尝试使用“cmd.exe”作为可执行文件。 And feed it with anything you want after "/C" key for example. 例如,在“/ C”键之后用任何你想要的东西喂它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM