Copying command-line results to the clipboard in Vista

In this month’s MCP magazine, Greg Shields wrote about using clip.exe to get command line output onto the clipboard where you can easily use it by pasting into your favourite app, such as Notepad, OneNote or Excel (if you need to parse the results down).

“Like you, I’ve struggled with the multistep process to get data from the results of a command into a text file. If you want to run the runme.bat script and capture the results, you’d launch the command and copy and paste the results into Notepad or another text editor. Or, you might pipe the results to a file using the > character. If you’re particularly skillful, you could redirect both stdout and stderr to a text file with the text string:

runme.bat 1> results.txt 2>&1

But what if you simply wanted to pipe the results to the clipboard?
Way back in the old days, the Windows NT and Windows 2000 Resource Kit had a tool called clip.exe that allowed for this. Just run:

runme.bat | clip

and use Ctrl+V to paste the results into your text file. With Windows 2003, the tool moved out of the Resource Kit and is now installed natively with the operating system. But there appeared to be nothing comparable for Windows XP, so I slowly forgot about it.
That is, until recently — when I realized that one could simply copy clip.exe from C:\Windows\Systems32 on any Windows 2003 Server to the same location on an XP workstation and rejoice for the happy return of Command Line Clippy!”

What Greg forgets to mention is that this functionality is also natively installed on Windows Vista, ready and available for easy use.

About ukcrmguru
I'm an MVP for Dynamics CRM, consultant, Microsoft Certified Trainer and self-confessed geek. I also lead the UK CRM User group when I'm not too busy with all that.

Comments are closed.

%d bloggers like this: