Solved

How do I redirect console output from cmd.exe for full-screen console apps

Posted on 2009-05-04
10
1,287 Views
Last Modified: 2013-12-17
How do I redirect console output from cmd.exe for full-screen console apps, e.g. telnet, edit, etc. I wish to gain access to application input & output.

I'm assuming that either the program (e.g. telnet) or the shell (e.g. cmd.exe) is making calls to the windows console functions, e.g. ReadConsoleOutput, WriteConsoleInput, etc. These functions fail when the STDIN, STDOUT and STDERR streams have been redirected. Does anyone know of code to get and redirect the info? Is it a matter of hooking all the console functions in user32.dll or kernel32.dll?

Thanks for any info.
0
Comment
Question by:geriatrix
  • 3
10 Comments
 

Author Comment

by:geriatrix
ID: 24331735
OK, platform is PC, OS = Windows XP/Vista, language = {VB.NET, C/C++, C#}. Related applications: maybe powershell.
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24345027
The angle of this article is slightly different, but what is of interest for you is the SpawnDumpConsole function. The code is in C++ but it comes with full source code: http://www.codeproject.com/KB/dialog/ConsoleAdapter.aspx
0
 
LVL 39

Assisted Solution

by:abel
abel earned 500 total points
ID: 24345034
Alternatively, though I did not try this myself, this article provides you insightful information (six pages) about the inner workings and how you can deal with them from code: http://www.devsource.com/c/a/Using-VS/Working-with-Console-Screen-Buffers-in-NET/1/
0
 
LVL 39

Expert Comment

by:abel
ID: 24946000
I showed a link with a solution. This particular question is quite hard to solve, but on the locations of these links is enough information, including full solutions. I don't think this question should be deleted (I already had it in my KB for that matter...)
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question