Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Windows cmd.exe Command-Prompt ► ««« »»»

Redirect CMD command output to a file, with an example?


Use redirection operators to redirect or save the results of a command prompt in a file on MS Server OS or Windows 11, 10, ...!



As with MAC OS and Linux, the solution is very simple also under all Microsoft Windows and server systems to redirect a CMD command output to a file, here is a simple example that administrators like when remote accessing the web server 2019, 2016, 2012, ... is used!

How to use redirection operators! The easiest way to learn how to use these redirection operators is to see a few examples!

Content / example / tips:

1.) ... Example 1 directory structure!
2.) ... Example 2 List all Windows accounts!
3.) ... What is the advantage of redirection in a file and alternatives?
4.) ... Example 3 Batch file with several commands in a text file! !
5.) ... Example 4: For Windows 11/10 and MS Server 2019 Ctrl + A Ctrl + C!

1.) Example 1 directory structure!


C: Windows>tree C:\ > d:\directory_structure_of_c.txt



In this example, stores the directory structure all the folders and subfolders that tree normally after running are all displayed on the screen, in a file named directory_structure_of_c.txt

As you can see, the ">" redirect operator goes between the tree command and the name of the file that is used here. Attention! If the file already exists, it will be overwritten. If it doesn't already exist, it will be created.

Tip: 
Although a file is created if it doesn't already exist, folders are not created. To output the results of the command to a file in a specific folder that does not yet exist, first create the folder and run the command.



2.) Example 2 List all Windows accounts!


C: Windows>net user > d:\user_on_PC.txt

 


In this example, a list of all Windows accounts that are normally displayed on the screen after running net user is saved in a file with the name user_on_PC.txt

3.) What is the advantage of redirection in a file and alternatives?

In the case of very long console returns (output text), these cannot be edited or viewed on the screen, especially if it is a few megabits of data, only a program such as ColorConsole can help, which is designed for up to 50 megabits.

►  ColorConsole - More color and fun for your Windows console !



A little hint:
In contrast to the standard CMD.EXE, the ColorConsole has full copy paste support. This means that complete output texts or only partial areas can be copied directly. Yes, even with the complete color syntax. 
 
In short, there is enormous time-saving potential in this oh so small and inconspicuous program.  

(Image-1) Alternative CMD prompt as command output example!
Alternative CMD prompt as command output example!

-
▲ Back to the top ▲



4.) Example 3 Batch file with several commands in a text file!



If you don't want to use an alternative CMD for Windows, you can use the following example:

Two commands in a text file

Test.bat after issue.txt

The batch file 


(

ping bing.de

ping google.de

)> command_output.txt 



(Image-2) Batch file with several commands in a text file!
Batch file with several commands in a text file!


-
▲ Back to the top ▲

5.) Example 4: For Windows 10 and MS Server 2019 Ctrl + A Ctrl + C!




Commands then use Ctrl + A to select everything and copy them to the clipboard with Ctrl + C

Tip: ►►  Change the buffer size of the text at the Windows command prompt!



(Image-3) Copy CMD command output to clipboard!
Copy CMD command output to clipboard!

-
▲ Back to the top ▲




FAQ 41: Updated on: 23 June 2022 08:42 Windows
Windows-Console

Secure File Removal Using the ERASE Command, Examples?


Please use Eraser to delete sensitive data. It can also clean digital SD memory cards of all recoverable data As with Linux, Appels Mac OS and other systems
Windows-Console

Create multiple guest accounts on Windows 11, 10, 8.1, MS Server with commands?


It is very easy to create multiple guest accounts for guest users under Windows 11 / 10 / 8.1 / 7, or Windows Server by using command lines It is not only
Windows-Console

Check if there is a file path via PowerShell?


The solution is very simple to use a command in PowerShell to check whether a file path or folder path is available The solution is very simple with the test-path command,
Windows-Console

Use batch file to start multiple programs on Windows 11, 10...!


Start several programs at the same time via a batch file in order to save several clicks, is very popular on MS Windows 11, 10, desktop and server operating
Windows-Console

How do I force a logoff via command line, Windows 11, 10, 8.1, .. and MS Server?


The solution is very simple, to force that the logoff is carried out via the command line under Microsoft Windows 11 / 10 / 8.1 / 7 If some programs have
Windows-Console

Create bootable USB stick with Windows, but how?


Creating a bootable USB stick as an installation medium for Windows is no magic Everyone comes to this point and wants a solution that is very simple to
Windows-Console

Command line to change the drive label of a drive!


The solution with the cmd.exe is very easy to change the drive designation of a drive via command line on all MS Windows OS Under Windows, you can easily

»»

  My question is not there in the FAQ
Asked questions on this answer:
  1. Windows command line output to file without line break?
  2. Is there a solution or possibility at the end of the script to copy or save the contents of the CMD window to a text file?
  3. Redirect cmd to file, redirect Windows output to file?
  4. Command redirect Windows output to a file?
  5. I have a batch script with several queries and flow routines, I am wondering if it is possible to redirect it to a text file via script of various commands, i.e. the output of the batch file?
  6. Powershell command output console redirect variable?
  7. I have a batch script with multiple routines, now do I want to detailed a log file instead of just output in the CMD?
  8. Is there an option with little effort to save several lines from a script into a file or to copy the complete command prompt output, i.e. the text buffer content?
  9. I want to redirect the output of the command prompt out if this is possible on Windows?
  10. How can all outputs of the cmd be redirected in a batch file on Windows 10?
  11. Append Windows output redirection to file?
  12. Is there a way to call any batch file so that it is not output on the screen, but instead is written to a LOG.TXT?
  13. How can I redirect all output from a batch file?
  14. But I want to log the whole thing in a little more detail instead of just the output in the CMD, so I want a command output redirection as a command in, for example, file_output.txt and all commands in this file redirect does that work?
  15. Attach Windows command line output to file?
  16. I want to redirect output of two or more commands to an output.txt file from the command prompt?
  17. I want to redirect output from the batch file, I like to create batch files over and over again with a few simple commands to collect the valuable information on my system, now I want the batch file to contain commands to get all the commands put together in a batch file and if it is running I want the batch file to print the results to a text file as a log when run, is there a command I can add that would redirect this to a file?
  18. Is it possible at the end of the script to copy or save the content of the command prompt / CMD window directly into a text file?
  19. What do you do when you call up a batch file, and when I have a lot of information I want to write all the information in a log file! What do I have to state?
  20. Redirect console output from command prompt to file?
Keywords: windows, 11, 10, server, eleven, console, redirect, command, output, file, with, example, redirection, operators, save, results, prompt, Questions, Answers, Software




    

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + CpuFrequenz
  + MultiClipBoardSlots
  + OnlyStopWatch
  + KeepMouseSpeedOK
  + NonCompressibleFiles
  + 4ur-Windows-8-Mouse-Balls
  + 12-Ants
  + Q-Dir
  + DirPrintOK
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Windows 2021 | Windows 10 | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2023 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.093


► What does it mean for programs: Runs from Windows 5.0 and higher? ◄

► I don't like how the Explorer pages are displayed! ◄

► Is there a list of WMIC commands on MS Windows? ◄

This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....