Solved

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

Posted on 2009-05-04
10
1,291 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Asp.Net Session Question 2 49
SSIS GUID Variable 2 58
What is needed to become a DBA? 7 56
Help with modifying xml file using VB.NET 5 13
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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…

752 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