Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to capture/redirect the standard output of a process that I did not launch, in .net?

If I know the process identifier, is there some mechanism in .net (or pinvoke as last resort) to capture/redirect the standard output of a process that I did not launch?

like image 428
SFun28 Avatar asked Nov 14 '22 22:11

SFun28


1 Answers

You could AttachConsole your process to the console of the other process, and then use the usual console I/O functions to read and write from it.

Remember to use FreeConsole to detach from the process' current console first.

like image 128
CesarGon Avatar answered Dec 16 '22 09:12

CesarGon