Copying CMD.exe using batch file?
Moderator: DosItHelp
-
- Posts: 1
- Joined: 08 Mar 2019 12:22
Copying CMD.exe using batch file?
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?
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
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?
Maybe there is more clarification needed for your question, but how about this:reptilemikael wrote: ↑08 Mar 2019 12:28is it possible to create a batch file to copy a open command prompt text? if so how? if not is there a different way?
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?
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
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
For example
Code: Select all
dir | clip
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