Windows Command-line tools are great for troubleshooting, as well as automation. But, 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 will come in handy.
This post explains how to copy or redirect Command Prompt output to a file or the clipboard.
Table of Contents
- Open a Command Prompt window
- Copy Command Prompt output to Clipboard
- Redirect Command-line output to a file
- Take a Screenshot
Copy Command Prompt Output Text to Clipboard or File
To open a Command Prompt window, press WinKey + R to launch the Run dialog. Type in
cmd.exe and press Ok. In Windows 8.1 and Windows 10, you can right-click Start and click Command Prompt. There are several other ways to open Command Prompt.
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.)
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.
To copy the command prompt output to the clipboard, use one of the methods.
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 the output of your console tool or command to the clipboard using the built-in
Clip.exe tool by piping the output. The command you’d run is:
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 the clipboard, you can paste it into a text editor. For example, you can open Notepad and paste (Ctrl + V) the contents there.
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:
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:
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
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.
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
The first command would create a new file (as a single
> symbol is used) named
info.txt. Subsequent commands would output the results to the existing
info.txt file (double
In some cases, you may not require the text output, and a screenshot is sufficient. Win + 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 for a detailed guide.
I hope this guide helped you learn how to copy or redirect Command Prompt output to a file or the clipboard.