How to Copy Command Prompt Output Text to Clipboard or Save to File?

Windows Command-line tools are great for troubleshooting, as well as automation. If you’re stumped when a tech support guy on the phone asks you to run a built-in console command and copy the output displayed for diagnosing a problem, these Command Prompt basics would come in handy.

Table of Contents

Opening a Command Prompt window

To open a Command Prompt window, press WinKey + R to launch the Run dialog. Type in cmd.exe and press ENTER. In Windows 8.1 and higher, you can right-click Start and click Command Prompt. There are several other ways to open Command Prompt.

Command Prompt window

If the console tool you’re running or the operation you’re performing requires administrative privileges, you need to open Command Prompt as administrator (also known as “elevated Command Prompt”.)

Copying the output to clipboard

In the Command Prompt window, type in the command you want to run. For example, someone who’s helping you wants to know your system information by running SystemInfo command, type systeminfo and press ENTER.

copy command prompt output

To copy the command’s output text to clipboard, use one of the methods.

Using Keyboard shortcuts: Press Ctrl + A to select all text, and press {ENTER} to copy it to clipboard.

Using the Edit menu: Right-click the Command Prompt title bar, click Edit and click Select All. Repeat the same and this time, click “Copy” from the Edit menu.

copy command prompt output

Using Clip.exe console tool: The Clip.exe console tool is built-in to Windows, starting with Windows Vista and up to Windows 10. This tool copies the data redirected or passed to it, into the clipboard. You can redirect output of your console tool or command to clipboard using the built-in Clip.exe tool by piping the output. The command you’d run is:

systeminfo |clip

That would copy the output of the systeminfo command to the Windows Clipboard. This is done by Clip.exe receiving the command-line output directly.

Once the output is sent to clipboard, you can paste it in any editor window. You can open Notepad and paste (Ctrl + V) the contents there.

copy command prompt output

Redirecting the output to a new file

You can redirect the command-line output to a file instead of Clipboard. This method can be useful if the output is too lengthy containing several hundreds of lines that can easily exceed the Command Prompt window’s screen buffer size. To output the results to a file, use this syntax/examples:

systeminfo >%temp%\systeminfo.txt

That would create a file named systeminfo.txt in the user’s Temp folder. To write the output to a file on your desktop, you’d use:

systeminfo >%userprofile%\desktop\systeminfo.txt

Redirecting the output to a file by appending

The previous command would create a new file or erase the previous file (if one exists with the same name). If you want to append the command-line output to a file, use double greater-than symbols >>, as below:

ipconfig >>%userprofile%\desktop\systeminfo.txt
systeminfo >>%userprofile%\desktop\systeminfo.txt

That would output the contents of Ipconfig and Systeminfo commands to the same file. If a file exists with the same name systeminfo.txt, it would be used. Otherwise a new file would be created.

Another example

ipconfig >%userprofile%\desktop\info.txt
sc query wuauserv >>%userprofile%\desktop\info.txt
dir d:\tools\*.exe >>%userprofile%\desktop\info.txt
dir C:\Windows\System32\Tasks /s /b >>%userprofile%\desktop\info.txt

Command Prompt window

The first command would create a new file (as single > symbol is used) named info.txt. Subsequent commands would output the results to the existing info.txt file (double >> symbol).

Take a Screenshot

In some cases you may not require the text output, and a screenshot is sufficient. WinKey + PrntScrn keystroke is used to take a screenshot quickly in Windows 8 and 10. Or use the excellent built-in Snipping Tool. Check out How to Take a Screenshot in Windows? Different Ways Explained for a detailed guide.

Hope that helps! Let’s know your comments.

About the author

Ramesh Srinivasan founded back in 2005. He is passionate about Microsoft technologies and has a vast experience in the ITeS industry — delivering support for Microsoft's consumer products. He has been a Microsoft MVP [2003 to 2012] who contributes to various Windows support forums.

2 thoughts on “How to Copy Command Prompt Output Text to Clipboard or Save to File?

Comments are closed.