简体   繁体   中英

How to pass commands to already running command prompt in C#?

假设我在系统中打开了命令提示符,现在我只想通过c#程序将命令传递给该打开的命令提示符窗口,而我不想打开命令提示符窗口的新实例来执行我​​正在通过C#程序传递的命令。

I'm not quite sure what you mean "open new instance" to execute arguments which you passed already. However, if you are not quite sure how to parse intensively command line arguments you can take a reference of this link :

Best way to parse command line arguments

You need to send keys to an open application. The belolw link will help you

http://www.codeproject.com/Articles/18366/Sending-Keystrokes-to-another-Application-in-C

您可以尝试使用FindWindow API和SendKeys。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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