How To Save The Output Of A CMD Command To A Text File Or To The Clipboard In Windows

How To Save The Output Of A CMD Command To A Text File In Windows:- Sometimes when you execute a command in the Command Prompt, you might feel the need to save it to an external file or to copy it to the clipboard. For example, you are getting an error code everytime you are executing a command. In that case, you might want the output of the command to be saved somewhere so that you can share it with a friend or post it on a forum to get help from the techies there. Is there a quick way to do this? Yes there is! Dive into the article to learn all about this super cool hack.

Steps To Save The Output Of A CMD Command To A Text File


  • Launch the Command Prompt in the administrator mode. For that, start typing in cmd to the search box and when the search results appear, right click on Command Prompt and choose the Run as administrator option. Some commands need administrator privileges to execute. That’s why we are opening the Command Prompt in the administrator mode.



  • Once the Command Prompt opens up in the administrator mode, type in your command followed by >, followed by the file name to which you want the output of the command to be saved. In the following screenshot, I have taken the command ipconfig as an example. You can type in any cmd command of your choice for similar results.
    format:  yourCommand > filename.txt



  • The output of your command will be saved at the default location: C:\Windows\System32.



  • If you do not want your file to be saved at the default location, you can specify the location and save your file there. I have specified Desktop as my file location as shown as an example in the screenshot given below. The format would be same as before, the only change would be in the location specifics.



  • Now you can go to the location where the file is saved and double click on it to view its contents.



  • That’s it. The output of your command is successfully saved.


Steps To Copy The Output Of A CMD Command To Clipboard


  • If you just want the output of a command to be copied to the clipboard, you can follow the following format:
    yourCommand | clip

Note: The screenshot given below is just an example. You can save the output of any command. It doesn’t have to be ipconfig itself.


  • Now open notepad or any other editor application and try to execute the paste command. For that you can either right click anywhere and choose paste option or you can use the key combinations of CTRL+V.



  • That’s it. The output of the command will now be successfully pasted to your editor from the clipboard.


Hope you found the article useful. If you have any doubts regarding any of the steps, please feel free to leave comments, we would be happy to help. Meanwhile, you could check out our articles on the topics 20 Useful Windows Commands For Managing Files and 6 Basic Windows Command Lines Everyone Should Know.

Share on FacebookShare on Google+Tweet about this on TwitterShare on RedditShare on StumbleUponShare on LinkedIn

Leave a Reply

Your email address will not be published.