Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now