Copy CMD Output Directly To The Clipboard

Martin Brinkmann
Oct 20, 2011
Updated • Mar 26, 2017
Tutorials, Windows tips

The Windows command line prompt can be handy at times, and sometimes even the only option to execute a specific command on the operating system. You sometimes may need to copy the output of a command to the Windows Clipboard, for instance to use the output in another application.

Most users that I know handle this either by sending the output to a file with the > filename.ext command or by frantically trying to figure out a way to select and copy the output content in the command prompt window directly. Side note: The latter option got a lot better with the release of Windows 10.

Both methods are not really straightforward and need more time than the process should take in first place. Thankfully though there is a way to copy command prompt outputs directly to the Windows Clipboard, it is only lesser known.

Open the command prompt as usual. You can open it with standard rights or elevated rights by right-clicking on the icon in the start menu and selecting to run it as an administrator. Another option for that is to hold down the Shift-key and the Ctrl-key before selecting the Command Prompt link in the start menu.

Copy CMD Output Directly To The Clipboard

windows clipboard output

Once there you can copy any output to the clipboard by appending | clip at the end of the command. A basic example is the dir command which outputs all folders and files of the current directory level directly in the command prompt. Please note that you won't see the output anymore on the screen as it is redirected to the clipboard when you use the | clip command.

  • dir -- output in the command prompt
  • dir > test.txt -- output copied to the file test.txt in the same directory.
  • dir | clip -- output copied to the clipboard

The directory command is only a basic example to demonstrate the effect of the | clip command. You can obviously use it for complex commands and outputs as well. Whenever you use the clip command everything that is part of the output is copied to the Windows clipboard.

Did you know about the clip output command? If not, how did you copy the command prompt output until now?

Copy CMD Output Directly To The Clipboard
Article Name
Copy CMD Output Directly To The Clipboard
The guide explains how you can send any command prompt output to the Windows Clipboard right away using the | clip parameter at the end of commands.
Ghacks Technology News

Previous Post: «
Next Post: «


  1. Harsha said on October 22, 2012 at 10:06 am

    Thank you, Martin! Getting output directly into clip saves a lot of time and effort.

    With other tools like AutoHotKey etc, we can further simplify our effort!

  2. MAW74656 said on August 14, 2012 at 12:00 am

    Am I the only one who used screenshots to capture output? Very embarrassing, but true.

  3. Ross Presser said on October 25, 2011 at 6:48 am

    It’s neat that clip.exe will accept stdin (piped or redirected from a file). I didn’t know about it, and now that I do I can think of many uses.

    But why on earth didn’t they make it completely useful by having clip.exe also copy the clipboard contents to stdout?

    Cygwin’s /dev/clipboard can be used in both directions, but of course it requires the cygwin emulation layer. That’s a price I’m prepared to pay on my local machine but not on the servers I manage.

  4. ECLiPSE said on October 23, 2011 at 5:11 am

    Nice tip, Martin!

    I use right click, choose MARK, then select whatever I want with the mouse (while left clicking) then right click again, and voilá, my selection gets copied to the clipboard.
    This method gives you more control over what you need to copy.

  5. whino said on October 22, 2011 at 7:57 pm

    I’m not sure how legal it is to copy the clip.exe from a Windows Server install to a Windows XP machine, so here’s an alternative:
    Here are some ports of common GNU utilities to native Win32. In this context, native means the executables do only depend on the Microsoft C-runtime (msvcrt.dll) and not an emulation layer like that provided by Cygwin tools.

    It has the tools pclip and gclip as well as many other useful utilities, fully legal, fully free, and with source code.

    The download link on their site doesn’t work however, so use the sourceforge download:

    1. Martin Brinkmann said on October 22, 2011 at 9:18 pm

      Great, thanks for the alternative.

  6. cyrux said on October 22, 2011 at 12:51 pm

    perfecto pero en un OS Win 7 en español seria? Inside Win7 Spanish where scribe? “clip=?” thanks

  7. Gemmo said on October 21, 2011 at 11:47 pm

    I once knew every command and switch in DOS prior to the Windows advent. Things changed but I still drop back to DOS for a lot of things I do; this is a very welcome addition and thanks a million for it. It will be used frequently, I guarantee it.

  8. TechBuzzard said on October 21, 2011 at 6:31 pm

    Impressive piece of information Martin, and tips like this will elicit a lot of reader responses :-).

  9. Masoud Sh. said on October 21, 2011 at 4:40 pm


  10. Wombat1369 said on October 21, 2011 at 3:31 pm

    Good find or a useful tip. Thanks for sharing it.

  11. Roman ShaRP said on October 21, 2011 at 10:57 am

    Didn’t know this. Thanks, and more thanks for the tip on XP!

  12. Steve said on October 20, 2011 at 11:02 pm

    I had no idea about this, this is really cool, thanks

  13. Visitor said on October 20, 2011 at 10:12 pm

    Wow, it’s really cool! I’m from MS DOS era, but I didn’t know.

  14. Robert Palmar said on October 20, 2011 at 9:32 pm

    Great tip. I too was unaware of this.
    I have been using the edit menu.

  15. Paul(us) said on October 20, 2011 at 8:40 pm

    Nice readable – and ferry useful article. perhaps its an idea to rehash/refresh us with all possible dos commands and (and this would be an extensive task) (perhaps series of ) what you can do with the dos commands article(s)

    1. Dean said on October 21, 2011 at 11:59 pm

      Just to echo Paul(US); I’ve been messing about in the DOS shell and realised just how much I’ve forgotten – Windows has made me lazy.

      Had to Google the DOS version of pwd – just a simple CD… makes me feel a little embarrassed at how much I’ve forgotten!

  16. Meena Bassem said on October 20, 2011 at 8:06 pm

    wow, man you’re awesome. i’ve always wanted to do it but never really knew it’s possible. Thanks alot man

  17. bitsum said on October 20, 2011 at 7:29 pm

    The app menu for the console window (upper left of window) allows you to copy and paste by ‘marking’ text to copy to the clipboard, or paste. It is not as convenient as piping it to ‘clip’, which I admit I was unaware of.

    1. bitsum said on October 20, 2011 at 7:31 pm

      Specifically within the ‘edit’ submenu

  18. The_Flames said on October 20, 2011 at 7:28 pm

    is this a Vista/7 only command, or does this work with earlier version of windows?

    1. Martin Brinkmann said on October 20, 2011 at 7:32 pm

      According to this article from 2006 ( it does not ship with XP but can be used under XP. The blog post links to a download on a respected site. It is probably best to place it in system32 or another path variable folder.

  19. Dean said on October 20, 2011 at 7:10 pm

    That is cool – I’ve always prefered to work in DOS but sometimes you’re forced into Windows.

    I had no idea about using the pipe to send to clipboard (Always assumed pipe was a Unix thing).

    I ended up using an ahk script to paste into the command line – this just tops it all off.


    1. Martin Brinkmann said on October 20, 2011 at 7:24 pm

      It is pretty handy considering that it is a built-in feature.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.