从您自己的控制台应用程序中读取命令并将其发送到操作系统控制台命令提示符以执行 [英] Read commands from your own console app developed and send it to the Operating system Console command prompt to execute

查看:92
本文介绍了从您自己的控制台应用程序中读取命令并将其发送到操作系统控制台命令提示符以执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



这是一个简单的问题。



实际上我想开发一个控制台应用程序将读取我们进入它的命令,然后尽管我自己编写逻辑执行这些命令,但我希望操作系统命令提示符执行它。



这可能吗?



请帮助!!!



示例场景:



我运行我的控制台应用程序,然后输入md sam。现在这将在当前文件夹中创建一个名为sam的目录,但是我需要在我的控制台应用程序中编写代码,以便通过阅读此

来执行此操作,并且可能会编写一个切换案例('' md'')然后是Directoryinfo.CreateDirectory()。像这样的东西



但我只需要通过我的控制台应用程序读取md sam,然后将命令发送到OS命令提示符,它将执行其余的操作对我们来说。



有可能吗?



请帮助!!!!





谢谢!!

Sam

Hi Guys,

A quick question here.

Actually I want to develop a console application which would read the commands which we enter into it and then in spite of writing the logic myself for those commands to execute, I want the OS command prompt to do it.

Is this possible?

Please help!!!

Example scenario :

I run my console app and i enter like "md sam". Now this will create a directory named sam in the current folder, but i need to write the code in my console app for it to do this by reading this
and may be write a switch case(''md'') then Directoryinfo.CreateDirectory(). something like this

But i just need to read the "md sam" by my console app and then send the command to OS command prompt and it will do the remaining things for us.

Is it possible??

Please help !!!!


Thanks!!
Sam

推荐答案

你可以使用 进程执行此操作(但为什么?) .Start 方法 [ ^ ]。


U必须定义您传递给控制台应用程序的参数,并且只需使用命令提示符运行控制台应用程序传递价值。
U have to define arguments what ever u pass to the console application and just the run the console application using command prompt by passing values.


这篇关于从您自己的控制台应用程序中读取命令并将其发送到操作系统控制台命令提示符以执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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