<cliché>Have you ever wondered why Windows didn't include the ability to capture a
directory listing, so that you could print it out or paste it into a document?

Many years ago, I wrote my first console clipboard access routines with QuickBasic, using DOS interrupts. In fact, they were the very first samples I ever submitted to BasicPro Magazine, for their consideration. Sent them directly to Jim Fawcette, as I recall. He never responded, and they languished alone on my hard drive. Time marched on, I wrote dozens of columns for FTP, but for whatever reason never returned to this cool little project. I've been using these utilities for years, and frequently send friends to download them. I finally decided it was time to share with everyone.

In a nutshell, these tools offer you the ability to read and write the Windows clipboard from the console. They read standard input and write standard output. In the usage dumps below, in addition to noting the various switches available for each command, be sure to take a look at the examples offered for ideas on ways to pipe and redirect the i/o.


C:\>SetClip /?

SetClipboard, Version 1.00.0057,
Copyright (c)2002-07 Karl E. Peterson, All Rights Reserved

Sends text from StdInput to clipboard.

   /?       Displays help (this, such as it is)
   /clear   Clears the clipboard and exits
   /text    Places input on clipboard as plain text (default)
   /rtf     Places input on clipboard as RTF
   /html    Places input on clipboard as HTML

   /add     Adds input without first clearing clipboard
   /append  Appends input to clipboard (text only)
   /plain   Clears all clipboard formats except plain text

   The /add switch tells SetClip to *not* clear the clipboard before adding
   new input to it. If the input format already exists on the clipboard, it
   will be overwritten regardless. This switch is useful if you want to
   preserve existing clipboard data in other formats.

   The /append switch is only available when placing plain text onto the
   clipboard. When used, existing text on the clipboard remains, and new
   input is appended. May be used with /add to preserve other formats.

   The /plain switch is meant to be used to clean-up the mess left on the
   clipboard by other applications. This switch simply removes every format
   other than plain text, thus allowing a clean paste into other apps.

Exit codes:
   0 Success
   1 Failure

Usage examples:
   C:\>dir \winnt\system32 | SetClip
   C:\>SetClip < \setuplog.txt
   C:\>type \INetPub\wwwroot\index.htm | SetClip /html
   C:\>SetClip /clear

*** FREEWARE ***

C:\>GetClip /?

GetClipboard, Version 1.00.0037,
Copyright (c)2002-07 Karl E. Peterson, All Rights Reserved

Sends text from Windows clipboard to standard output.

   /?       Displays help (this, such as it is)
   /text    Requests plain text from clipboard (default)
   /rtf     Requests RTF from clipboard
   /html    Requests HTML from clipboard
   /frag    Requests HTML Fragment from clipboard
   /enum    Enumerates formats currently on clipboard

Usage examples:
   C:\>GetClip /html | find "<title>"
   C:\>GetClip > somefile.txt

Exit codes:
   0 = Normal operation
   1 = No text on clipboard
   2 = No RTF on clipboard
   3 = No HTML on clipboard
   4 = Clipboard empty on enumeration

*** FREEWARE ***


Download   See distribution notes below for complete details on what's allowed. 
Sorry, no source is included with this free tool.

Download, 40Kb, Last Updated: May 1, 2009
Please note: These tools require the VB6/SP5 runtime.

Freeware Distribution

You may freely share this package with your friends and colleagues. Please do not repost it anywhere on the publicly accessible internet. This simple request is aimed at ensuring that only the most recent bits are available for download. Feel free to link directly to this page, as the download link will always be here, but don't count on the actual file location to remain constant.

See Also

The following resources may also be of interest:

  • ClipFileCopy - Shows how Explorer copies and pastes files (actually, file lists) to/from the clipboard.
  • ClipEx - Recreates functionality of the Clipboard object for VBA.
  • CmdLine - Read and parse the command line into an argument array or test for switch presence and parameters.
  • Console - Full console application development support from within VB5/6 IDE.