I have a command line program running and I would like to send additional commands to it (I.E. Once it is already running) How can I do this in C#?
Asked
Active
Viewed 1.2k times
6
-
Is it expecting commands to be sent to it? Does it listening for it? Need more information on your command line program you have developed. – Lav Jun 19 '11 at 03:59
3 Answers
12
If the process is started by your C# program, then you can use Process.StandardInput to send commands to it.
If you are sending command to other processes, you can use the SendKey class as demoed in here.

Lindsay
- 161
- 3
3
A few possibilities:

Community
- 1
- 1

Mitch Wheat
- 295,962
- 43
- 465
- 541
-
3Or optionally [How can I send keypresses to a running process object?](http://stackoverflow.com/questions/2686865/how-can-i-send-keypresses-to-a-running-process-object) – TrueWill Jun 19 '11 at 04:06
1
If you are talking about an interactive console program you just need to use Console.Readline() to get the input from the console and process it in your code. If you are talking about something more complex read about Inter-process communication (IPC).

zad
- 3,355
- 2
- 24
- 25