Page 1 of 1

Copying CMD.exe using batch file?

Posted: 08 Mar 2019 12:28
by reptilemikael
is it possible to create a batch file to copy a open command prompt text? if so how? if not is there a different way?

Re: Copying CMD.exe using batch file?

Posted: 10 Mar 2019 06:23
by aGerman
There is no command to copy the content of a console window programmatically. Right click on the title bar, Edit->Select all, then hit Enter to copy the content into the clipboard.

It would be possible to write a tool in another language to copy the content of the window from where the tool was called (EDIT okay, just wrote one https://sourceforge.net/projects/concpy/). But it wouldn't be reasonable to try to copy something out of a foreign window.

Steffen

Re: Copying CMD.exe using batch file?

Posted: 25 Jun 2019 07:29
by Looge
reptilemikael wrote:
08 Mar 2019 12:28
is it possible to create a batch file to copy a open command prompt text? if so how? if not is there a different way?
Maybe there is more clarification needed for your question, but how about this:

cmd.exe | tee C:\output.log

This will launch another session, but the TEE command will allow to :
- see the screen input/output as normal
- log (most) output to a file

The magic here is that contrary to all "normal" behaviour, the redirected output does not replace the normal screen output, it just adds redirected output to be logged, .. in addition to having normal output.
This is thanks to the TEE-function, which is a Unix/Linux thingy.
Many Windows port exist for it, like here: https://www.robvanderwoude.com/unixports.php

As stated, I'm not sure that is the kind of thing you are wanting to do, but if it is ..

Re: Copying CMD.exe using batch file?

Posted: 26 Jun 2019 07:49
by dbenham
If you know that you want to copy the contents of the window before the window content is generated, then you can use the CLIP command.

For example

Code: Select all

dir | clip
But only the output is captured, not the command itself.

If you want the commands to be included, then put the commands in a batch file with @ECHO ON, and then pipe that result to CLIP.


Dave Benham