Solved

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

Posted on 2009-05-04
10
1,295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…

624 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