Manage Learn to apply best practices and optimize your operations.

Ten hidden Windows command prompt tricks

9/12

Using Windows Redirector to store command outputs to a text file

Source:  Nirmal Sharma; Photograph: Getty Images/Ingram Publishing

Keyboard Symbol ">" -- also known as Redirector -- allows you to store the output of a command in a text file. The use of ">" (Redirector) is commonly seen in batch scripting, but you can use it to capture the output of a command in a text file quickly as listed below:

DIR C:\TempCMD > MyOutput.txt

By default, Redirector does not capture errors returned by a command. If you need to capture errors also in the text file, then you must use "2>&1" at the end of the command line.

The first command is executed to stop a service named "W32TimeT." Since there is no service by the name of "W32TimeT," the command returns an error. The error is not captured in the text file, even if you use Redirector.

The second command uses "2>&1" to capture the output of the command with errors in the text file successfully. To quickly open MyOutPut.txt, run the "Start MyOutput.txt" command. This tip also works in Windows XP.

View All Photo Stories
Virtual Desktop
SearchWindowsServer
Close