Redirect the output of the exe batch file


Redirect the output of the exe batch file



I want to execute a certain batch file and redirect its console output to a text control in visual c++ or redirect the console output at the same time the logs/echo are showing.




Writing utf16 to file in binary mode

1:



How to fill a vector with non-trivial initial values?
Basically, you have to make the run process to write to a pipe, and to read the output of this pipe..
Hide a tab previously added to Qt TabWidget
[EDIT] I know how SciTE does that (you can take a look at the source: win32/SciTEWin.cxx, ExecuteOne function), I searched a slightly more generic way, found How to spawn console processes with redirected standard handles from Microsoft itself.
If you seach CreatePipe PeekNamedPipe CreateProcess keyword, for example, you might find other examples..
General way to reset a member variable to its original value using the stack?


Enumerating network shared directories in C++ / MFC


How do I write a short literal in C++?

2:



C++ Variant
Another option is to use Boost.Process (Boost.Process is not (yet) an official Boost C++ library.


MFC: What on earth is a CSplitterWnd Caret?
It must be downloaded and installed separately)
.. The example "Child.4 - Reading from a child using asynchronous I/O" shows how to redirect the output of the child process into a C++ stream (and later access the content).. Example "Child.4 - Reading from a child using asynchronous I/O" show how to use Boost.Process togehter with Boost.Asio to access the childs I/O asynchronous.. The advantages of this method is, that Boost.Process supports the Windows API and POSIX API..


3:


There's an article here on CodeProject that shows how to do this..


4:


If elegance is not a priority then a really simple solution might be to redirect the output to a file, and then read in the file contents..



84 out of 100 based on 84 user ratings 834 reviews