Move mouse over headlines for article summary. Click on news headlines to open the full article in a new browser tab or window. For your protection, this site does not use URL shorteners.
Mobile View on your SmartPhone is now supported.

Capture Command Prompt Output in Windows 7

January 30, 2010 -- When working in a Windows Command (CMD) Prompt (aka DOS prompt -- although no longer DOS), you might wonder how to cut and paste displayed text into another Windows program.

This function would be useful if you are trying to document some aspect of your system status that is not easily captured in an existing program. For example, you might want to save a copy of the output when using ipconfig which is used to view the status of your netword card configuration (eg. current IP address and gateway). Having the results in text format is likely more useful than a screen capture. I'll show you three ways to accomplish this task.

Method 1:

In Windows XP, Vista, and Windows 7 you can easily redirect your output at the command level to a text file and then edit that file. Use the symbol > (Shift + greater than arrow) to indicate output redirection.

ipconfig > tmp

The above command will send the output from the ipconfig command into a new file called "tmp" in the current directory. If the file already exists, it will be replaced. By using the following command, you can append your output to an existing file. Note the use of the double > symbol to indicate this function.

ping google.com >> tmp

At this point you can simply use Notepad to open the file where it will be available for editing, and then use cut and paste operations to move into another Windows program as needed.

notepad tmp



Method 2:

Right-click anywhere in the Command prompt window, and click Select All. All of the text from the current command scroll buffer will be highlighted. Press the Enter key. The output will be copied to the Windows clipboard. You can use the Clear Screen cls command to clear the scroll buffer prior to entering any commands you wish to capture. Open Notepad for example, and paste the clipboard contents to Notepad using Ctrl-V.



Method 3:

Starting with Windows Vista and continuing with Windows 7, there is a small utility included called clip.exe which can be used to redirect output directly to the Windows Clipboard. Enter clip /? at the command prompt to get a description of this command.

CLIP

Description:
Redirects output of command line tools to the Windows clipboard.
This text output can then be pasted into other programs.

Parameter List:
/? Displays this help message.

Examples:
DIR | CLIP Places a copy of the current directory listing into the Windows clipboard.

CLIP < README.TXT Places a copy of the text from readme.txt on to the Windows clipboard.


We use the clip command in conjunction with the "|" pipe operator. The "|" symbol is often found above the "\" key on your keyboard. This operator sends ("pipes") output from one command to the input of another. Thus,

ipconfig | clip

takes the output from ipconfig, sends it to clip, which in turn places that information on the Windows clipboard. From there, we can open Notepad and using Ctrl-V, paste this information into Notepad (or any other Windows program we chose).


You can copy the clip.exe program from Windows 7 and it will work under Windows XP.

--MLJ

0 comments:

Post a Comment

Comments and suggestions are welcome. If you are having specific problems, please provide enough details for us to followup with possible solutions.