Tuesday, February 25, 2014

How to copy command prompt outputs to the Windows Clipboard

The Windows command prompt or line is not really something that many Windows users need to work with on a daily basis, or at all, anymore. While it can still be helpful at times, for instance to quickly look up your IP address or display open connections, it is probably fair to say that the majority of Windows users have little to no command prompt experience.
That's not necessarily a bad thing depending on what the computer is used for. If you are just using it to browse the Internet and use Office, then there may never be a need to dive deeper into the inner workings of the system.
I have to admit that I'm also not using the command prompt that much anymore. I do use it occasionally but not regularly anymore as I do not really need to use it for the things I'm doing.
I learned a couple of tricks over the years though, for instance that you can write the output of any command to a text file by adding > textname.txt to the end of the command.

copy windows command prompt clipboard

There is however another possibility, and that is to write the output to the Windows Clipboard. This is done with the clip command that you add to your command that you want executed.
Basic examples of how this looks like are dir | clip to write the contents of the directory to the Clipboard, or ipconfig | clip to write the ipconfig information to it instead.
You can use parameters in the command as you see fit which are executed just as before.
It depends on the data output if you should write the output to a file or the clipboard. If you want to paste it in an online forum, chat or other program then you may want to use the clip command to speed things up. If you need more control over it then a text file may be more appropriate.
There is also an option to write text file data directly to the clipboard. This is probably only useful for batch files though as you can open the document to copy its contents as well in the Windows gui.
Anyway, to copy the contents of a text document to the clipboard use the clip < textname.txt command. Source: http://www.ghacks.net