Categories
Design

How to save the command prompt’s output to a text file in windows

Jason Fitzpatrick is the Senior Smart Home Editor at How-To Geek. He has over a decade of experience in publishing and has authored thousands of articles at How-To Geek, Review Geek, LifeSavvy, and Lifehacker. Jason served as Lifehacker’s Weekend Editor before he joined How-To Geek. Read more.

How to save the command prompt’s output to a text file in windows

Saving the output of a Windows Command Prompt command is a great way to get a nice neat copy to share with support staff, analyze longer outputs using your favorite text editor, or otherwise interact with the output with more flexibility than staying in the command window allows for.

To redirect the output of a command to a text file instead of printing it to the screen in the command window, we simply need to execute the command and append it with the “>” angle bracket symbol—called, appropriately enough, a redirection.

If, for example, you wanted to save the output of the DIR function to a text file instead of scrolling for page after page on your screen in the command window, you would execute the command

like so, where we’ve run the DIR command from the C:\ directory and saved the output to the root directory of the D drive as “c-drive-directory-output.txt”.

Notice that the output is not displayed in the command window above, but when we open the text document, we see the full command output:

How to save the command prompt’s output to a text file in windows

Any command that has a command window output (no matter how big or small) can be appended with > filename.txt and the output will be saved to the specified text file.

In addition to executing the command as a one-off affair, you can also tweak the command slightly in order to dump sequential output to the same text file for your convenience. Let’s say, for example, you want to send the output of the same command to the same text file before and after you make some change (like, say, rebooting your router and acquiring a new IP address). You can first issue the command with a single angel bracket “>” and then repeat future instances of the same command with a double angle bracket “>>”.

If you are working with windows command prompt you can directly view the output directly in the command promt window itself. Now suppose you want to save the output/command result to a text file or print it to a hard copy.

For example if you want to save your system information, one thing that you can do is copy from the command prompt window and paste it in a text file and then if you want you can print it.

Instead, there is a better way to easily save the output directly from the command prompt window to a file by using the redirection command.

To use the redirect command, just use the symbol “ > ” and the file name at the end of the command you want to execute.

For example to redirect output of the systeminfo command to the file systeminfo.txt, enter the following command at the prompt: systeminfo > systeminfo.txt

This will create the file called systeminfo.txt in the current directory you are at, with the output results of systeminfo command.

Now if you want the file to be created at another location on your hard drive, enter the full path to that location: systeminfo >c:\systeminfo.txt

When using a single redirect command, it will always over-write the contents of the file before writing any new data. That is if you have the same file name. So if you want to append data to an existing file, use two redirection symbols as shown in the following example: dir c:\files >> c:\systeminfo.txt

This example adds the output of the dir (directory) command to the end of the file – systeminfo.txt.

If you want to directly redirect the output to devices such as a printer then you can follow the following example:

Say you have a printer connected to LPT1. You would use the following command:
dir c:\files >LPT1

This will print the output for you. You can also use PRN or CON to output data results.

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.
  • The output of your command will be saved at the default location: C:WindowsSystem32.
  • 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:

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.

How to save the command prompt’s output to a text file in windows

  • 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.

On Windows 10, the ability to save the output of a PowerShell or Command Prompt command to a text file can come in handy in many scenarios. For example, when you’re troubleshooting a problem, it’s a convenient way to export and analyze the command output, or you can share the output with someone else who can help. You can print a command output to a text file to save system configurations for documentation purposes, and more.

Although you could just select the content, right-click the selection to copy the content to the clipboard, and then paste on a text file, this method requires additional steps, which you can avoid with a single command-line using the redirect output to file function.

In this Windows 10 guide, we’ll walk you through the steps to save a command output to a text file whether you’re using Command Prompt or PowerShell.

  • How to save command output to file using Command Prompt
  • How to save command output to file using PowerShell

How to save command output to file using Command Prompt

To save a command output to a text file using Command Prompt, use these steps:

  1. Open Start.
  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

Type the following command to save the output to a text file and press Enter:

In the command make sure to replace “YOUR-COMMAND” with your command-line and “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and file name to store the output.

(Optional) If you want to save the output, and view the result on the screen, then use this command and press Enter:

YOUR-COMMAND > c:\PATH\TO\FOLDER\OUTPUT.txt | type c:\PATH\TO\FOLDER\OUTPUT.txt

In the command make sure to replace “YOUR-COMMAND” with your command-line and “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and filename to store and view the output.

Quick tip: If you’re having issues viewing the file, you can use the type c:\PATH\TO\FOLDER\OUTPUT.txt command after step No. 3.

Once you complete the steps, the command output will be saved into a text file, which you can then review or share with tech support.

How to save command output to file using PowerShell

To save a command output to a text file using PowerShell, use these steps:

  1. Open Start.
  2. Search for PowerShell, right-click the top result, and select the Run as administrator option.

Type the following command to save the output to a text file and press Enter:

YOUR-COMMAND | Out-File -FilePath c:\PATH\TO\FOLDER\OUTPUT.txt

In the command make sure to replace “YOUR-COMMAND” with the command-line that you want and “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and file name to store the output.

(Optional) Type the following command to view the saved output on the screen and press Enter:

Get-Content -Path c:\PATH\TO\FOLDER\OUTPUT.txt

In the command make sure to replace “c:\PATH\TO\FOLDER\OUTPUT.txt” with the path and file name with the output content.

After completing the steps, the PowerShell command will save the result into a text file on the location that you specified.

We’re focusing this guide on Windows 10, but you can also use these instructions on Windows 8.1 and Windows 7.

More Windows 10 resources

For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:

‘Goldeneye 007’ Xbox achievements have been discovered

A full list of Xbox achievements has been leaked online for the Nintendo 64 classic, Goldeneye 007. Read on to learn more details on this surprising development.

Here’s why Linux is now my primary OS going into 2022

I’m no longer using Windows as the OS on my primary PC. In fact, it’s no longer installed on a secondary drive. Here’s why you may want to consider making the switch.

Microsoft, we need to talk about the Xbox app on PC

Microsoft’s PC Game Pass service is great. But as the publisher looks to expand on its PC gaming foundations, it’s clear that the current state of the Xbox app just isn’t cutting it.

These 10 apps are must-haves apps for any new Windows PC

You just purchased a new PC and set it up, and now you’re looking for some great apps. Look no further. These are the best apps for your new Windows 10 PC.

PowerShell is a command-line shell designed particularly for system administrators. It helps administrators to manage and automate the administration of Windows operating systems and the Apps running on it. PowerShell has the ability to save the outputs of commands you run in it into a file which you can later view, analyze, and share it with someone else for troubleshooting.

In this article, I will demonstrate the steps to save command output to a file. In the windows search bar, type powershell.exe and press Enter on the keyboard to launch PowerShell.

Send output to file in PowerShell

In the PowerShell window, enter the command followed by Out-File -FilePath .\filename.txt

Replace the Command, FilePath, and FileName parameters with your own command, file path, and names simultaneously. If the file does not exist, Out-File will create the file with name and path specified.

For instance, I want to output the ipconfig result to a file named ip.txt and save it on the desktop. The command will be:

Running the above command will save the output of ipconfig as a file ip.txt on desktop. If a file already exists with some content, Out-file will overwrite it.

How to save the command prompt’s output to a text file in windows

Prevent overwriting of output file

To prevent already existing file from being overwritten, add -NoClobber parameter after the above command.

-NoClobber will prevent overwriting and displays a message that file already exist.

Append the output to an existing file

If you want to add another output in the same file and also do not want to remove or overwrite the data, add –Append parameter before the file name as shown in the below command.

The above command will add the output of Ping command in the same text file without overwriting it.

How to save the command prompt’s output to a text file in windows

In this article, I described the method to save the PowerShell commands output in a file. You can save the output of the commands in a text file, prevent it from overwriting, and to add the output of another command in the same file.

The network statistics (netstat ) command is a networking tool used for troubleshooting and configuration, that can also serve as a monitoring tool for connections over the network. Both incoming and outgoing connections, routing tables, port listening, and usage statistics are common uses for this command. Here are some related contents: How to logoff, restart, or shutdown Windows PC or Server remotely via Command Prompt and PowerShell, Error: Telnet is not recognized as an internal or external command, and how to configure OpenSSH Server. Netstat is a cross-platform command, this means it’s also available in other operating systems like macOS and Linux.

See the image below for the syntax and text output 😉 That is it 🙂
– See the following guides on “how to prevent a remote shutdown and restart in Windows 10, how to allow only admin users (administrators) to shut down and reboot Windows Server 2012, how to prevent users from shutting down in a Virtual Machine and Handy Command-Prompt Shutdown Commands.

how to save netstat to test and troubleshoot

Below is a table of the Netstat Command Syntax.

Option Explanation
netstat Execute the netstat command alone to show a relatively simple list of all active TCP connections which, for each one, will show the local IP address (your computer), the foreign IP address (the other computer or network device), along with their respective port numbers, as well as the TCP state.
-a This switch displays active TCP connections, TCP connections with the listening state, as well as UDP ports that are being listened to.
-b This netstat switch is very similar to the -o switch listed below, but instead of displaying the PID, will display the process’s actual file name. Using -b over -o might seem like it’s saving you a step or two but using it can sometimes greatly extend the time it takes netstat to fully execute.
-e Use this switch with the netstat command to show statistics about your network connection. This data includes bytes, unicast packets, non-unicast packets, discards, errors, and unknown protocols received and sent since the connection was established.
-f The -f switch will force the netstat command to display the Fully Qualified Domain Name (FQDN) for each foreign IP address when possible.
-n Use the -n switch to prevent netstat from attempting to determine hostnames for foreign IP addresses. Depending on your current network connections, using this switch could considerably reduce the time it takes for netstat to fully execute.
-o A handy option for many troubleshooting tasks, the -o switch displays the process identifier (PID) associated with each displayed connection. See the example below for more about using netstat -o.
-p Use the -p switch to show connections or statistics only for a particular protocol. You can not define more than one protocol at once, nor can you execute netstat with -p without defining a protocol.
protocol When specifying a protocol with the -p option, you can use tcp, udp, tcpv6, or udpv6. If you use -s with -p to view statistics by protocol, you can use icmp, ip, icmpv6, or ipv6 in addition to the first four I mentioned.
-r Execute netstat with -r to show the IP routing table. This is the same as using the route command to execute route print.
-s The -s option can be used with the netstat command to show detailed statistics by protocol. You can limit the statistics shown to a particular protocol by using the -soption and specifying that protocol, but be sure to use -s before -p protocol when using the switches together.
-t Use the -t switch to show the current TCP chimney offload state in place of the typically displayed TCP state.
-x Use the -x option to show all NetworkDirect listeners, connections, and shared endpoints.
-y The -y switch can be used to show the TCP connection template for all connection. You cannot use -y with any other netstat option.
time_interval This is the time, in seconds, that you’d like the netstat command to re-execute automatically, stopping only when you use Ctrl-C to end the loop.
/? Use the help switch to show details about the netstat command’s several options.

For clarity said due to the recent comment i received, here are some screenshoots of a new test.

We can sort a text file using the windows inbuilt sort command. Below you can find the syntax of sort command.

Sort a text file:

A text file can be sorted using the below simple command.

For example, to sort the file data.txt, the command would be
sort data.txt

The above command prints the sorted contents of the file in the console. To save the output into another file, you can use
/o switch as shown below.

Alternatively, you can user redirection operator.

Advanced options for sorting:

Sort the contents in reverse order

If you are sorting big files, then /M switch will help you to finish the sorting quickly. Be default, sort command uses only 160 KB of space to store the file contents in main memory. Increasing this limit, will increase the performance of the sort operation. To let the sort command use 10MB of memory, we can run the below command.

I think the /M parameter is stated incorrectly here, please see the command line help info about /M:

/M[EMORY] kilobytes Specifies amount of main memory to use for
the sort, in kilobytes. The memory size is
always constrained to be a minimum of 160
kilobytes. If the memory size is specified
the exact amount will be used for the sort,
regardless of how much main memory is
available.

The best performance is usually achieved by
not specifying a memory size. By default the
sort will be done with one pass (no temporary
file) if it fits in the default maximum
memory size, otherwise the sort will be done
in two passes (with the partially sorted data
being stored in a temporary file) such that
the amounts of memory used for both the sort
and merge passes are equal. The default
maximum memory size is 90% of available main
memory if both the input and output are
files, and 45% of main memory otherwise.

If /M not specified, sort will try to utilize the as mush memory as possible, under this condition, the 160kb is the minimum memory not the maximum. If you specified /M, it will use that amount of memory exactly.

This doesn’t work on Windows 7.
Looks like the switches have disappeared.
“help sort” just produces an error now too.

By Stella | Follow | Last Updated November 24, 2020

Summary :

How to save the command prompt’s output to a text file in windows

You can open the Task Manager to view the currently running processes on your computer. But you may not be satisfied with this display. You may want to output the Windows list processes to a text file. This post from MiniTool Software will show you three easy methods that can save the running processes list to a text file.

You can go to the Task Manager to see what processes are currently running. But it is just an interface that shows you the running situations of the running processes. You may want to save the running processes list to a text. In this post, we will talk about the Windows list processes issue.

How to save the command prompt’s output to a text file in windows

How to list all running processes on Windows to a text file?

  1. Use the Tasklist command
  2. Use Windows PowerShell
  3. Use Windows Command Line Utility (WMIC)

Windows List Processes to Text Using the Tasklist Command

This is the easiest method to output the running process list to a text file.

Here is a guide:

2. Type tasklist and press Enter to see the list of the processes that are running on your Windows.

How to save the command prompt’s output to a text file in windows

3. Type tasklist > c:\process_list.txt and press Enter.

How to save the command prompt’s output to a text file in windows

4. Go to drive C: to find and open the text file that is named as process_list.

How to save the command prompt’s output to a text file in windows

The text file is as follows. You can see the process names, PID Session Name, Session#, and Mem Usage.

How to save the command prompt’s output to a text file in windows

Windows List Processes to Text Using Windows PowerShell

You can also use Windows PowerShell to save the running processes list to a text. Here are the things you should do:

1. Right-click on Start and select Windows PowerShell (Admin).

2. Type get-process and press Enter. Then, this tool will show you the currently running processes on your computer.

How to save the command prompt’s output to a text file in windows

On the above interface, you can discover that this tool shows more information than tasklist does:

  • Handles: The number of handles that the process has opened
  • NPM(K): The non-paged memory the process is using (in kilobytes)
  • PM(K): The pageable memory the process is using (in kilobytes)
  • WS(K): The pages in memory that has been recently used by the process (in kilobytes)
  • VM(M): The virtual memory that is used by the process (in megabytes)
  • CPU(s): The processor time that is used by the process across all processors (in seconds)
  • ID: The process ID of the process
  • ProcessName: The name of the process

3. To output this process list to a text file, you need to type Get-Process | Out-File -FilePath .\Process_list.txt and then press Enter.

The text file will be saved to the path where you run the command. You can find it and open it to see the process list. If you don’t know the location, you can also search for process_list in File Explorer to find it.

How to save the command prompt’s output to a text file in windows

How to search for files in Windows 10? In this article, we will show you three methods to perform a Windows 10 file search by name, type, and file contents.

Windows List Processes to Text Using WMIC

Using Windows Command Line Utility (WMIC) can also output the Windows list processes to a text file and this tool will show you up to 44 parameters for every active process.

You need to do this job via Command Prompt. Here is a guide:

  1. Run Command Prompt as administrator.
  2. Type wmic /OUTPUT:C:\ProcessList.txt PROCESS get /all and press Enter.
  3. Go to drive C: to find the text file that is named as ProcessList.

This time, you may don’t want to open this ProcessList file using Notepad because there are so many parameters. You can use Excel.exe to open it:

2. Click Open to open a new file.

3. Find the ProcessList.txt file from C drive and click Open. Here, if you can’t find that file, you need to change the File Type option to All Files.

4. On the Text Import Wizard window, you need to check Delimited and My data has headers.

How to save the command prompt’s output to a text file in windows

5. Click Next to continue.

6. Check Space under the Delimiters section and check Treat consecutive delimiters as one.

How to save the command prompt’s output to a text file in windows

7. Click Next to continue.

8. Click Finish.

After these steps, the text file will be opened in an excel file. It is convenient to see these parameters in an excel file.

How to save the command prompt’s output to a text file in windows

Bottom Line

These are the three methods to out Windows list processes to a text file. You can select one method that you want to use to have a try. Should you have any related issues, you can let us know in the comment.

  • Facebook
  • Twitter
  • Linkedin
  • Reddit

ABOUT THE AUTHOR

How to save the command prompt’s output to a text file in windows

Position: Columnist

Stella has been working in MiniTool Software as an English Editor for more than 4 years. Her articles mainly cover the fields of data recovery including storage media data recovery and phone data recovery, YouTube videos download, partition management, and video conversions.

It is really a big frustration when your personal computer, i.e. desktop or laptop starts acting up. However, there is is a little sense of relief when you finally understand that the problem is not that serious and it can easily be solved by reinstalling the operating system or Windows if you are a Windows user. But, Microsoft does not roll out Windows with all the necessary software and programs, and that’s why you need to install additional programs to make your computer more efficient for all your needs. If you have installed multiple programs on your Windows computer and working on a new Windows installation then you could miss out a few of the most important programs while installing them again on your new setup.

Well, you can easily download the programs from the internet and install it on a computer, and several tools like Ninite makes it easier to install most programs. But if you are using a laptop and you need some program on the go, downloading a piece of software might not be possible, and that’s when it becomes really important to note down all the programs that you have installed on the current version of Windows before you start with re-installation. If your Windows has crashed to an extent, where you cannot log in to your computer, getting a list of programs might not be possible. However, things are not that bad all the time. So, today I will talk about two different ways you can create a list of all the programs installed on your computer before you go install Windows on your system.

Export a list of installed programs on a Windows 10/7 PC

Just open ‘ Programs and Features ’ on your computer, and capture one or multiple screenshots, having the name of all the installed programs. After you capture the screenshots, keep the screenshots on a different storage device, like flash storage, or on the cloud safely, making sure, the screenshots will be available even after reinstalling Windows. That way, you can see the list of programs again after the reinstallation of Windows is complete, and install all the programs one by one.

How to save the command prompt’s output to a text file in windows

Using Windows PowerShell

Open Windows PowerShell on your Windows computer. You can open Windows PowerShell with or without administrator privileges. You can open Windows PowerShell by right-clicking on the Start menu.

How to save the command prompt’s output to a text file in windows

Now type in the following command and hit the enter key to find a list of the programs installed on your computer.

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize

How to save the command prompt’s output to a text file in windows

However, this command will just show you the list of installed programs, their version number, size, and installation date. Now you need to save the output to a text file. So the command will go as follows.

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > “Path”

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > D:\programs.txt

This command will save the output of the program to the text file with the name ‘ programs.txt ’ in the D drive. You will not get any output on the screen. The path can be different in your case.

How to save the command prompt’s output to a text file in windows

This command works only on Windows PowerShell. Using this command on Command Prompt is not going to work.

Using Command Prompt

If you are comfortable on Command Prompt, there is a different way to find the list of installed programs, and then export it to a file. To do that, type in the following command and hit the enter key

The list of installed programs and their version number will be in front of you.

How to save the command prompt’s output to a text file in windows

However, if you don’t want to get the same in a text file, the command is similar, and here is the format.

The command will export the list of installed programs and the version number to the file ‘ programs1.txt ’ within D drive, and there will no subsequent output on the screen.

How to save the command prompt’s output to a text file in windows

The second one is way easier to get the list of programs, however, if you are using Microsoft PowerShell, you will get to see more details compared to that of the method using Command Prompt.

These are the two useful ways of finding a list of installed programs on a Windows computer. Additionally, you can also download and use third-party programs and uninstallers to do the same task of exporting the list of installed programs to a text file. After the list is exported it will really be easier for you to install all the programs without a hitch.

So, that was all about, how you can export a list of all the programs installed on a Windows computer, to a text file. Do you have any questions? Feel free to comment on the same below.

When we run a command on a terminal on Linux it generates some output of that command. Sometimes we need the output result of the commands. Today we are going to see how to save the output of the command.

Using Redirections in Linux:

We can use the redirections operators to save the output of commands into files. Redirection operators redirect the output of a command to the file instead of the output terminal.

There are two main redirection operators in Linux:

  • >
  • >>

Example 1:

The first operator is “>” which is used to redirect the output of a command to the file, but this operator erases all existing data in that file and overwrites the command output,

Let’s see one example of > redirection operator:

How to save the command prompt’s output to a text file in windows

In the above image, we can see that the previous content of the output.txt file gets erased and the output of the ls command is written into the file.

Example 2:

Now let’s see about the second redirection operator is >>. Using this operator we can append the output of the command to the file. It does not erase any previous content of the file.

Let’s see the example of >> operator

How to save the command prompt’s output to a text file in windows

In the above image, we can see that the output of the command is appended to the output.txt file without erasing the content stored in that file.

If the file mentioned after the Redirection operator in not exist then it will create automatically.

Using tee command:

When we use the redirection operator the output is going to the file only the redirection operator does not print it on the terminal. To see the output on the terminal and also save it into the file we can use the tee command. It sends the output of the file as well as to the terminal.

First, let’s see how to use the tee operator using the pipeline. Following is the syntax of using the tee operator:

Now let’s see one example of the tee command:

How to save the command prompt’s output to a text file in windows

We can see in the above image the output is redirected to the terminal as well as the output.txt file.

To append the output of the command to the file use the –a option with the tee command. Here is the syntax of the command:

Table of Contents

Introduction

If you want to see which Group Policies are applied to a client, you can run the RSOP command (Resultant Set of Policies) to export an RSOP report.

You can also export the RSOP results can be accomplished via the GUI as well as via Powershell.

In this blog post, I explain how to export the results from RSOP to an HTML report using Powershell.

If you are interested in learning more about Powershell, I highly recommend watching a Pluralsight course on the topic.

What is the GPResult command?

GPResult, or Group Policy Result, is the result of all policies applied to the machine. GPresult displays the result of all policies applied on the device, both for the user and computer.

You should run GPResult if you want to understand what group policies are applied to the machine.

How to use GPResult to export results to a text file

Gpresult parameters

Here are the gpresult parameters that are available. You can always use gpresult /? . If you want to find the different switches. These can be run both locally and remotely.

Example of gpresult output

Use the below command to export the GPResult output to a text file on the local computer. Note that you should run this from an elevated command prompt or elevated Powershell prompt to retrieve all the details.

In my example, I use /v for verbose information for both the local user and machine.

What is the RSOP command line?

The RSOP or Resultant Set of Policies command gathers all Active Directory Group Policies for the user account and computer settings applied to a device.

This is similar to the gpresult command but shows the results in the same way you would when configuring a Group Policy.
The look and feel is similar to that of the Local Group Policy (gpedit.msc) and the Group Policy Manager MMC console in Active Directory.

How to export an RSOP report

How to run RSOP from the command-line

Open an elevated command prompt (CMD) or Powershell. Run the command to generate RSOP data:

RSOP will now gather which Group Policies have been applied for your client.

Note: As mentioned in the text, “Starting with Microsoft Windows Vista Service Pack 1 (SP1), the Resultant Set of Policies (RSOP) report does not show all Microsoft Group Policy settings. To see the full set of Microsoft Group Policy settings applied for a computer or user, use the command-line tool gpresult.
This means that it is OK to use RSOP, but if you want to be sure that all Groupm Policies are included, use gpresult instead.

How to save the command prompt’s output to a text file in windowsResultant set of Policies

Gather RSOP results using Powershell

If you prefer to use Powershell, open an elevated Powershell window, and use the Get-GPResultantSetOfPolicy cmdlet.

Run RSOP for a remote computer using the Group Policy Management MMC

If you want to get the RSOP results from a remote computer connected to an Active Directory domain, you can gather summary data via the Group Policy Management console.

This is possible for both the user and for the computer. In the report, you will see which security groups the user or device is a member of and which Group Policy Objects are applied to the resource.

Export RSOP command to HTML using Powershell for a Remote Computer

In this example, I retrieve the Resultant Set of Policies (RSOP) for user Daniel in the Contoso domain, who uses the computer Windows10-Client. The output is in HTML, and the filename is D:\rsop.html.

Run the following command to save the report to an HTML file. In this example, I set the scope user to Contoso\Daniel and on a remote computer.

Conclusion

Using Powershell to export the results from RSOP is a much faster way than using the GUI. How do you export these results? Please leave a comment below!

If you are interested in learning more about Powershell, I highly recommend watching a Pluralsight course on the topic.

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!

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 !

(Image-1) Alternative CMD prompt as command output example!
How to save the command prompt’s output to a text file in windows

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

(Image-2) Batch file with several commands in a text file!
How to save the command prompt’s output to a text file in windows

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

Hey, Scripting Guy! I’m trying to write a script that will run Fsutil.exe against all the drives on a computer. That’s pretty easy. However, I’d like to have all the output written to a text file rather than displayed on screen; that’s the part that I haven’t had much luck with. Any help here would be greatly appreciated.
— RS

Hey, RS. Well, the Scripting Guys are back from Orlando – barely. The Scripting Guys were supposed to arrive back in Seattle last night around 9:30 PM, an arrival time that – among other things – would have given the Scripting Guy who writes this column time to write this column. However, thanks to a thunderstorm that hovered directly over the airport, the Scripting Guys spent several hours sitting on the tarmac in Orlando, and didn’t actually get home until 1:00 AM Seattle time. That’s bad; even worse is the fact that, since the Scripting Guys were operating on Eastern Daylight Time, 1:00 AM Seattle time felt like 4:00 AM to them.

And, of course, there was the little matter of sitting in a cramped little seat on an airplane for 8 hours, with a good portion of that devoted to sitting on the tarmac. As you might expect, the plane was parked right next to one of the gates, but no one was allowed to leave the plane. To help make up for this inconvenience, however, the airlines did give everyone a 1-ounce bag of “Savory Snack Mix,” for free!

In the end, that means that today’s Hey, Scripting Guy! column did not get written the night before as planned. As a matter of fact, a somewhat groggy Scripting Guy is pretty much writing today’s column while you read it; we only hope we can get that last paragraph typed in before you reach the end of the article.

Note. If you could go get a cup of coffee, go to the bathroom, or otherwise stop working for a few minutes that would help us out a great deal. Hey, there’s an idea: maybe you could do some work for a few minutes.

Nah; never mind about doing some work. After all, we’d never make anyone do something that we wouldn’t do ourselves.

With all that in mind, maybe we should see what we can do about answering RS’ question:

Note: If you run this script on Windows Vista, be sure to run as an administrator. (Right-click on Command Prompt and select Run As Administrator.) If you don’t, your output from this script will look something like this:

Probably not exactly what you were hoping for.

As you can see, this isn’t a particularly complicated script. (Which is good, because the Scripting Guy who writes this column isn’t particularly awake at the moment.) We kick the script off by creating instances of two COM objects: Wscript.Shell, the object we’ll use to actually run Fsutil.exe; and Scripting.FileSystemObject, the object we’ll use to write the output generated by Fsutil to a text file. After creating these two objects we connect to the WMI service on the local computer, then use this line of code to retrieve a collection of all the hard disks installed on that computer:

Two quick notes here. First, we noted that we connected to the WMI service on the local computer. Could we run this same script against a remote computer? Well, no, not in its current state; that’s because we can’t use the Windows Script Host Exec method to kick off Fsutil on a remote machine. We could use WMI to run Fsutil, but then we’d have difficulty capturing the output and writing it to a text file. If you need to run this script against a remote machine, you’ll probably have to rely on Windows Script Host’s remote capabilities. For more information on those capabilities, see the Microsoft Windows 2000 Scripting Guide.

Second, you might note that, in our WQL query, we restricted the returned data to instances of the Win32_LogicalDisk class where the DriveType is equal to 3. As you might have guessed, anything that has a drive type equal to 3 is a hard disk (fixed disk).

So what happens after we get back this collection of hard disks? Well, to begin with, we set up a For Each loop to walk us through each item in the collection:

Inside the loop, we grab the value of the DeviceID property (which just happens to be equivalent to the drive letter), and store that value in a variable named strDriveLetter. That brings us to this line of code:

What we’re doing here is constructing the Fsutil command to run against the first hard disk on the computer. Assuming that the first drive on the computer is drive C, RS needs to run the following command:

By amazing coincidence, that’s the exact same command we’re constructing: we’re combining the string value fsutil dirty query and the drive letter (DeviceID) C to form that exact command.

Once we have this command we can use Windows Script Host’s Exec method to execute the command:

We use the Exec method here (as opposed to the Run method) for one reason and one reason only: the Exec method allows us to capture any output generated by Fsutil. In fact, that’s what this block of code is for:

All we’re doing here is waiting patiently while Fsutil does its thing. Once the command-line tool has finished running, we use the ReadAll method to read in the output (from the StdOut stream) and store it in a variable named strResults.

Note. Incidentally, we can echo back the output as well as save it to a text file. If we also wanted to see the output onscreen we could simply add the line Wscript.Echo strResults immediately after the Loop statement.

The moment we exit the Do While loop we then append the new set of data to a variable named strText:

From there we go back to the top of the loop and repeat the process with the next hard drive on the computer.

After we’ve run Fsutil against all the drives on the machine we use this block of code to write the complete results to a text file:

Needless to say, there’s nothing very fancy going on here. In line 1 we’re using the CreateTextFile method to create a new text file named C:\Scripts\Test.txt. In line 2, we use the Write method to write the value of the variable strText to this new file. Finally, in line 3 we close the text file and call it a day.

By now we’re more than just a little late with today’s column, so we’ll have to wait until tomorrow to fill you in on our trip to Orlando. We will mention, however, that the Scripting Guys got to ride the all-new Simpsons ride at Universal Studios. What was that like? Well, it was fun, but by the time we finished our stomachs were feeling a little queasy, and we definitely needed to sit down for awhile before we could even think about doing anything else.

Which, now that you mention it, does sound a lot like what people experience when they read the Hey, Scripting Guy! column, doesn’t it?

This post was most recently updated on December 7th, 2020.

Every now and then, you run into a situation, where you’ll need to somehow dump the console output (or transcript) of running a console application. I’m actually going to argue it happens a lot more often than one would think – in my case, any time a customer requires a webjob or a function, that one would normally deploy to Azure, being ran on the servers of the customer. This post describes how to do that.

Problem

Table of Contents

Something breaks or the app crashes, and the error is logged to event log… But just the error, not the whole transcript. You’d like to get it all, to figure out what’s actually going on, but event log is not the way to go.

Or, maybe you’re investigating an error that happened to someone else, but only get screenshots of console or event log errors, whereas you’d want to get all the possible information about the problem instead.

Solution: redirection operator > to the rescue!

It’s luckily pretty easy. There are multiple ways to pipe, dump, redirect, log, mirror or just save the output to almost any imaginable target medium, but since I hate always googling for them (and for the life of me, I can’t seem to remember it by heart), I’m documenting my preferred way here.

No need to pipe output to file – because the redirection does natively what you could do with a pipe and “Out-File -FilePath” or similar command.

How to redirect output to file in Powershell?

You can direct the whole console output (and hence the whole PowerShell transcript for your executable) to a text file by doing something like this:

executable.exe > output.txt 2>&1

executable.exe *>&1 > output.txt

This method just writes everything from the console window to a file – as simple as that!

And of course, it’s not only limited to Command Prompt (cmd.exe) – it also works in Windows PowerShell:

If you want to verify this works, you can run the following in PowerShell – it first outputs “Hello World” and then simply redirects it to the file output.txt:

echo “Hello World” >output.txt 2>&1 .\output.txt

The second command should open output.txt in text editor – and it should contain “Hello World”.

Okay – so now it’s finally documented. Maybe I won’t have to google it the next time 🙂

Wait… But how is this better than copypasting from a console window?

If you’re not running your application unattended, you could just run the application and copy-paste from the window to your preferred location. That’s nice and easy! So what makes this method better?

A couple of things come to mind:

Why dumping console output to a file is better than just copypasting

  1. You can get the transcripts unattended. You don’t have to do anything yourself.
  2. This way, You won’t mess the copying up by selecting from areas of the output.
    • I don’t know about you, but I often mess up the copy-pasting from a console or PowerShell window. This method makes that impossible.
  3. This is the easiest way I’ve found to ask other people for the whole output/transcript of a console application run.
    • That’s really useful, because when I’m debugging, I really want the whole log, and not just the last few lines of red text!

Further thoughts

For more info and options about the output scenarios, see this Stack Overflow thread. If you want to read more about stdout and stderr, check this out.

However, a far more advanced scenario would be to save the output directly to Application Insights or something similar. For a lot of cases, this would be like shooting a fly with a bazooka, but for larger deployments, why not. Maybe worth a blog post later!

  • Author
  • Recent Posts

Antti Koskela is a proud digital native nomadic millennial full stack developer (is that enough funny buzzwords? That’s definitely enough funny buzzwords!), who works as Solutions Architect for Precio Fishbone, building delightful Digital Workplaces.

He’s been a developer from 2004 (starting with PHP and Java), and he’s been working on .NET projects, Azure, Office 365, SharePoint and a lot of other stuff. He’s also Microsoft MVP for Office Development.

This is his personal professional (e.g. professional, but definitely personal) blog.

  • The simplest fixes to “500 (Internal Server Error)” from Azurite – May 17, 2022
  • How to solve “Npgsql: 42883: function create_hypertable(…) does not exist”? – May 10, 2022
  • How to configure Azure PostgreSQL to allow Cloud Shell connections? – May 3, 2022

Posts Related to “How to output console or PowerShell transcript to a file in Windows”:

  • Fixing “Connect-SPOService : Identity Client Runtime Library (IDCRL) could not look up the realm information for a…
  • How to fix “The website does not support SharePoint Online credentials. The response status code is ‘Unauthorized'”
  • 5 ways to enable Custom Scripts for a SharePoint site collection

Search this site!

How to save the command prompt’s output to a text file in windows

About the site and the author

Welcome! You just stumbled upon the home page of an all-around artisan code crafter and Microsoft MVP, Antti “koskila” Koskela.

Don’t hesitate to leave comments. I read them all and try to reply as well!

More information about me in the About -section!

Solutions are worthless unless shared!

Check out the tech & programming tips, often about ASP.NET MVC, Entity Framework, Microsoft SharePoint Server & Online, Azure, Active Directory, Office 365 or other parts of the ever-growing and more and more intimidating stack that Microsoft offers us.

I’ve been developing both classic server stuff, but also (and actually especially) more cloud-oriented stuff in the past 15 years.

There’s an occasional post about software issues other than on Microsoft’s stack, and a rare post about hardware, too! And sometimes I might post about my sessions at different community events, or experiences as an expat living in a foreign country (in 2017, that country was the USA, in 2018 & 2019 Canada).

And since I’m hosting this site on WordPress, and boy does WordPress experience a lot of issues, I might also post something about solving those cases. Like PHP compatibility issues.

Want the latest tips directly to your inbox?

Like these posts and tips? You can get them automatically right as I post them! Enter your email here or check out the RSS feed here: https://www.koskila.net/feed/

And no worries – it’s just notifications of new posts coming in, nothing else 🙂

Automate tasks and more with batch files

How to save the command prompt’s output to a text file in windows

How to save the command prompt’s output to a text file in windows

  • Western Governors University
  • Tweet
  • Share
  • Email
  • Tweet
  • Share
  • Email

What To Know

  • Create a batch file in Windows 10 by typing your commands in a blank Notepad document, and saving it as .bat instead of .txt.
  • Commands include PAUSE, COPY, and CLS (clear).
  • To add comments, start a line with two colons and a space. Comments are useful to divide up a batch file into sections.

This article explains how to create a batch file in Windows 10 using the Notepad, how to add comments, and includes a list of common commands.

How to Create a Batch File in Windows 10

Creating a batch file in Windows 10 is as simple as typing the commands you want to run into a blank notepad document, then saving the document as a .bat file instead of a text document. You can then run the file by clicking on it, which will automatically launch the Windows command shell and execute your commands.

Here’s how to create a simple batch file in Windows 10:

Type Notepad into the search bar, and click the Notepad app when it appears in the results.

How to save the command prompt’s output to a text file in windows

Type the following into a blank Notepad document to create a simple batch file:

How to save the command prompt’s output to a text file in windows

Click File in the upper left corner of the Notepad window.

How to save the command prompt’s output to a text file in windows

Click Save as in the dropdown menu.

How to save the command prompt’s output to a text file in windows

Type a name for the script, like test.bat, and click Save.

How to save the command prompt’s output to a text file in windows

Make note of the location on your hard drive where the file is saved, as that’s where you’ll be able to find and execute it in the future.

Locate the file you just saved, and double click it.

How to save the command prompt’s output to a text file in windows

If the file was created correctly, you will see a command window that looks like this:

How to save the command prompt’s output to a text file in windows

Batch File Commands and Descriptions

A batch file is a special type of file that automatically opens a command window when activated. If you already know the commands that you need your file to execute, then you’re ready to go. Simply type the commands into Notepad in the manner outlined above, save as a .bat file, and open the batch file to execute the commands whenever you want.

If you’re not sure what to put in your file, keep in mind that a batch file is essentially an ordered list of commands that will execute via the Windows command prompt. Anything you could type manually into the command prompt, you can put in a batch file. The file will then execute each command, in order, from the top to the bottom.

Here are some useful commands to use in batch files, along with explanations of what they do:

  • @ECHO OFF: Disables display of the prompt. This is usually used at the beginning of a batch file for a cleaner display. You don’t need the @, but including it hides the ECHO OFF command as well.
  • ECHO: Prints the following text to the command window.
  • PAUSE: Causes the command window to remain open after the batch file is finished, or allows text in the window to be read before proceeding.
  • TITLE: Places a custom title in the title bar of the command window.
  • CLS: Clears the command window.
  • EXIT: Exits and closes the command window.
  • COPY: Copy one or more files.
  • REM: Record comments or remarks.
  • IPCONFIG: Display detailed IP information for each network adapter connected to your system.
  • PING: Sends an Internet Control Message Protocol (ICMP) echo request to an IP address or website.
  • TRACERT: Check your connection to an IP or website using ICMP.
  • SET: Used to set variables.
  • IF: Perform a conditional function based on user input or another variable.

Inserting Comments Into Batch Files

If you start a line in your batch file with two colons and a space, it won’t be executed. This allows you to easily insert comments into your batch file. Comments are useful to divide up a batch file into sections with a brief explanation as to the purpose of the section.

Here’s an example of a batch file with comments:

If you paste those commands into a batch file and run it, you’ll see an output like this:

How to save the command prompt’s output to a text file in windows

Comments aren’t necessary, but it is a useful option that you’ll tend to need more when creating complicated batch files with lots of sections.

Here’s a slightly more complicated batch file that uses a variety of commands, comments, and actually performs a useful task:

This file checks your internet connection using ipconfig and then pauses so you can examine it. It then pings google.com. Finally, it gives you the option to run the tracert command if you want. It then pauses a second time, allowing you to check the results before closing the window.

The final result looks like this:

How to save the command prompt’s output to a text file in windows

You can use any command prompt commands you like in a batch file, including variables and user interaction like the above example, writing information to other files, and more.

For the delivery I’ve been advised to print the full output of my program to a txt file. Also I need to print the execution time using the command “time” that I have implemented in my execution script.

The problem I’m having is that the program output is going correctly to the txt file, but the execution time is being showed in the terminal but it must be printed also in the txt file.

How to save the command prompt’s output to a text file in windows

2 Answers 2

It should work the way you want if you wrap the command in a command group or subshell:

In Bash, time is a shell key word for pipelines which interprets stream redirection to occur only on the timed command (pipeline); it also happens to be a common *nix utility program:

If you want to redirect streams to/from time you can either use command groups or sub-shells as explained in steeldriver’s answer or call the time(1) utility program explicitly:

or if you’re unsure about the full path of time

P.S.: You can save the output of the time(1) command to a file that is not connected to the command’s standard error output (which is the default) in case you want to preserve the timed program’s standard error output unaltered with the -o option. -a makes time append to that file instead of overwriting it.

To achieve the same effect with the time shell key word (as usual, use >> instead of > redirection to append instead of overwrite):

Or to save the time log but leave the timed program’s standard error output as it is:

Web Design, Development & Consulting by Allison Wong

How to save the command prompt’s output to a text file in windows

Export Windows folder filenames to a text file using Command Line

Scenario: You have a Windows folder containing a large amount of files that you need to have exported into one text file listing all the filenames. For instance, you might need to copy & paste those filenames into an Excel spreadsheet.

Here’s a quick and easy way to do it:

1. Open a Command Window (Start > Run > cmd )

How to save the command prompt’s output to a text file in windows

Open the command line

2. Navigate to the folder by using the cd command. If you need to move up a level, use cd .. If your folder name contains spaces, surround it with quotations.

How to save the command prompt’s output to a text file in windows

Commands to type

3. Type the command dir /b>filelist.txt

4. This will create the text file inside that folder. If you want the file output elsewhere, use a fully qualified name. Remember that Windows uses \ as the directory delimiter, not /

The “pretty” alternative: Simply drag and drop the folder into a Mozilla (Firefox) browser. The directory structure will be output in a pretty HTML document.

How to save the command prompt’s output to a text file in windows

Directory contents listed in an HTML page

15 thoughts on “ How to export filenames into a text file ”

Super useful. thank you very very much

Very super useful. This firefox trick is amazing!

There is a small windows utility File Names Export, you can do it with one click
http://filenames.bghot.com/download.php

Hi There – I’m a bit confused. When I open my dos box it says H:\>

I want to copy files from a folder on a shared drive with the following path
K:\Accounts Payable\Recs WA 2013\Supplier Account Recs A-M\340 – PE 30.04.2013
What am I doing wrong, I can’t seem to get it to work?
Thanks

neil thanks this was the utility i was looking for.

Very helpful. Thanks!

Super super super useful.Thanks a lot for posting this 😀

Nice, very helpful in deed. Thanks!
Stu

Super Useful . …Thanks a lot

You can simply paste the list into Excel, as follows:

1. Open Windows Explorer and select the source folder in the left pane.
2. Press Ctrl + A to select all items in the right pane.
3. Press and hold the Shift key, then right click on the selection.
4. From the context menu, choose “Copy as Path”.
5. Paste the list into Excel.

I wonder how can you make a list that will also include the directory along with the each file name.

Great stuff. I will use this!

Almost 9 year and this is still working, amazing, thank you!

“Copy as Path” option is simply superb

Any way to get the “owner” column of the date modified to come in as well?

How do you save a text file in Unix?

Once you have modified a file, press [Esc] shift to the command mode and press :w and hit [Enter] as shown below. To save the file and exit at the same time, you can use the ESC and key and hit [Enter] . Optionally, press [Esc] and type Shift + Z Z to save and exit the file.

How do I create a .TXT file in Unix?

How to create a file in Linux from terminal window?

  1. Create an empty text file named foo.txt: touch foo.bar. …
  2. Make a text file on Linux: cat > filename.txt.
  3. Add data and press CTRL + D to save the filename.txt when using cat on Linux.
  4. Run shell command: echo ‘This is a test’ > data.txt.
  5. Append text to existing file in Linux:

How do I change a .TXT file to a .sh file?

all you do, is first go to control panel, folder options, untick the option called hide the file extensions. when ur done, go to notepad and write the script for . sh file. and then go rename the file.

What is the command to save a file in Linux?

To save a file, you must first be in Command mode. Press Esc to enter Command mode, and then type :wq to write and quit the file.

More Linux resources.

Command Purpose
:wq or ZZ Save and quit/exit vi.
:q! Quit vi and do not save changes.
yy Yank (copy a line of text).

How do I save a text file in command prompt?

To save a command output to a text file using Command Prompt, use these steps: Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. In the command make sure to replace “YOUR-COMMAND” with your command-line and “c:PATHTOFOLDEROUTPUT.

Which command is used to save a file?

To save a file, you can click the Save icon in the top-left corner, click File>Save, or use the shortcut Ctrl+S (Command+S for Macs).

How do you create a text file?

There are several ways:

  1. The editor in your IDE will do fine. …
  2. Notepad is an editor that will create text files. …
  3. There are other editors that will also work. …
  4. Microsoft Word CAN create a text file, but you MUST save it correctly. …
  5. WordPad will save a text file, but again, the default type is RTF (Rich Text).

How do you create a file?

  1. Open an application (Word, PowerPoint, etc.) and create a new file like you normally would. …
  2. Click File.
  3. Click Save as.
  4. Select Box as the location where you’d like to save your file. If you have a particular folder that you’d like to save it to, select it.
  5. Name your file.
  6. Click Save.

How do I add a file in Unix?

User can create a new file using ‘Cat’ command in unix. Using shell prompt directly user can create a file. Using ‘Cat’ command user will able to open a specific file also. If user wants to process the file and append data to the specific file use ‘Cat’ command.

How do I make a text file executable in Linux?

This can be done by doing the following:

  1. Open a terminal.
  2. Browse to the folder where the executable file is stored.
  3. Type the following command: for any . bin file: sudo chmod +x filename.bin. for any .run file: sudo chmod +x filename.run.
  4. When asked for, type the required password and press Enter.

How do I create a .sh file?

Let us understand the steps in creating a Shell Script:

  1. Create a file using a vi editor(or any other editor). Name script file with extension . sh.
  2. Start the script with #! /bin/sh.
  3. Write some code.
  4. Save the script file as filename.sh.
  5. For executing the script type bash filename.sh.

How do I run a text file in Linux?

For all-purpose goal. No file in *nix environment (that’s created by user) would run unless you permit to do that. chmod +x filename.

When you open an executable text file, you can select from:

  1. Run executable text files when they are opened.
  2. View executable text files when they are opened.
  3. Ask each time.

How do I copy a file in Linux?

Copying Files with the cp Command

On Linux and Unix operating systems, the cp command is used for copying files and directories. If the destination file exists, it will be overwritten. To get a confirmation prompt before overwriting the files, use the -i option.

How do you save a file in Terminal?

  1. Press Ctrl + X or F2 to Exit. You will then be asked if you want to save.
  2. Press Ctrl + O or F3 and Ctrl + X or F2 for Save and Exit.

How create and save a file in Linux?

To create a new file run the cat command followed by the redirection operator > and the name of the file you want to create. Press Enter type the text and once you are done press the CRTL+D to save the files.

With PowerShell, you can redirect the output of any command to a text file. This is useful if you want to save the results returned by a PowerShell command or script. The PowerShell Out-File cmdlet is used to redirect output to a plain text file.

PowerShell has a class of Out- cmdlets. All these commands are used to redirect the received data to input devices (file, printer, screen). A list of PowerShell Out- cmdlets can be obtained as follows:

To display information about the syntax of the Out-File cmdlet, use the command:

How to save the command prompt’s output to a text file in windows

The Out-File cmdlet allows you to receive an object as input using the pipeline operator (|) and save the received data to a file.

For example, to get a list of running processes and save it to a file, run the command:

The path to the text file is specified as a parameter. The cmdlet will create a new proccess.txt file in the specified directory. If the specified directory doesn’t exist, the Out-File cmdlet will return an error:

Out-File : Could not find a part of the path ‘C:\ps\proc.txt’.

To open this text file in Notepad, run the command:

Hint. You won’t see anything on the screen when running the command because the Out-File cmdlet doesn’t produce any output. It only accepts incoming data and transfers its text interpretation to a file. The pipeline is cleared after it.

How to save the command prompt’s output to a text file in windows

You can save the list of running services to a file on your desktop using the Get-Service command:

To get the contents of the resulting file and display it in the PowerShell console, use the command:

By default, the Out-File cmdlet overwrites data in an existing file. If you want to prevent overwriting the file, use the NoClobber parameter. If you need to add new data to the end of the file, use the Append parameter:

You can use aliases instead of the Out-File cmdlet. They are similar to the redirection characters in the Windows Command Prompt (cmd.exe).

For example, you can send data to a file like this:

Or append new data to the end of the file:

How to save the command prompt’s output to a text file in windows

By default, Out-File saves the output to a Unicode encoded file (UCS-2 LE BOM).

You can use other encodings. They can be specified using the Encoding parameter. For example, to save the file in UTF-8:

Out-File formats the contents of the files to look like the output of the console. As a result, the output is truncated. You can specify the width of the line using the Width parameter (maximum value 2147483647):

How to save the command prompt’s output to a text file in windows

The following sections contain information on the various ways to create a file in MS-DOS or from the Windows Command Prompt. To proceed, you may read through each section in order or select from the below list.

  • Edit command
  • Copy con command
  • Start command
  • Listing the file after created

With the edit command

64-bit versions of Windows do not include the edit command. Instead of using edit, use the start command mentioned below.

If available and done properly, you’ll see a window similar to the example below.

How to save the command prompt’s output to a text file in windows

Once you have typed the information for the file myfile.txt, click File and choose Exit. If you do not have a mouse, see the edit command page for keyboard shortcuts and other navigation tips.

After clicking exit, if changes were made, the computer prompts you to save the file. Click Yes, and the file is created or overwritten with the new changes.

With copy con command

If you’re running an MS-DOS version 4.x or lower or you cannot use the edit or the start method you can also use copy con to create a file, as shown below.

Upon executing the above command, the cursor moves down one line to a blank line, allowing you to create the new file line by line. Once you are ready to create the file, press Enter to get to a blank line, press and hold Ctrl , press Z , and then let go of both keys. Once ^Z is shown on the screen, press Enter to save the file and exit.

Using the copy con method is a basic method to create a file that does not allow you to edit or fix any errors made while creating the line.

With the start command

The Windows Notepad and any text editor can also be started to create a file from the command line. The above command uses the start command to run Notepad and create myfile.txt. Once the file is saved in Notepad, that file is created in the same directory as where the start command was ran.

How to list the file once created

After the file is created using any of the above methods, you can list it using the dir command.

CMD Commands are the most preferred way of doing anything to computer experts and coders. Today we’re going to learn some useful commands that make our work easy and productive.

How to save the command prompt’s output to a text file in windows

Most Useful CMD Commands in Windows

1. Prompt Command

Usually, when we open our command prompt, we see in the left corner path of the current directory is written. So now we want to change it to our wish. Here Prompt command is used.

Syntax:

2. Title Command

Similarly, like prompt, when we open command prompt, the title of the application is like “C:\WINDOWS\system32\cmd.exe” is written. If we want to change it, then we use the title command.

Syntax:

How to save the command prompt’s output to a text file in windows

3. Color Command

When we see hackers in movies, having some green codes moving very fast on their computer screen, we get fascinated. Maybe you’ve got bored while working on a black and white screen. Then you can use the color command.

It requires two Hexadecimal digits. First for background and second for the foreground.

Example: color 02 makes it green text and black background.

4. Opening CMD Shortcut

There are many ways to open command prompt in windows. One we’re going to discuss today is, to open CMD in any folder. Yes, we’ll open it in any folder. Simply go to the address bar of that folder type “cmd” and hit “enter”.

How to save the command prompt’s output to a text file in windowsHow to save the command prompt’s output to a text file in windows

5. Hide Folders

When we hide any folder going from its properties, it gets showed as we check “Show hidden files” and the same thing happens when we use “attrib +h filename”. So now we are going to see a command that will hide your folder and there’s no any way to find it out again by others instead of you.

How to save the command prompt’s output to a text file in windows

Syntax:

How to save the command prompt’s output to a text file in windows

Note: Use “attrib -h -s -r file name ” to unhide the file.

6. Check your laptop’s battery health

So, the first command is for checking the battery health of the laptop. The command prompt will give you brief information and technical details about your laptop’s battery. To view a battery report, open a command prompt as an administrator and run the following command:

powercfg /batteryreport /output “C:\battery_report.html”

After hitting the enter key, your laptop’s battery report will be saved in your specified route in html format. (here we have given the path of the C drive).

How to save the command prompt’s output to a text file in windows

Battery report generated

7. Scan for system problems

With Windows command prompt, you can check all system files for any system problems like file corruption within a single command. Just open a command prompt in administrative mode and type:

This command will scan all protected system files, and replace corrupted files with a cached copy that is located in a compressed folder at %WinDir%\System32\dllcache. This process will take some time, so don’t close command prompt until verification gets completed.

How to save the command prompt’s output to a text file in windows

Scan for system problems

8. View your Windows license key

Sometimes you need to transfer your Windows 10 license to a new computer. At that time, your Windows product license key is very important. Let’s see how you can get your windows license key using a command prompt. As earlier, open a command prompt in administrative mode and after typing the command mentioned below, press the enter key.

wmic path softwarelicensingservice get OA3xOriginalProductKey

How to save the command prompt’s output to a text file in windows

Windows license key

9. Save folder trees to disk

Sometimes you can’t find an overview of all the nested folders on a drive and get confused about the location of a particular folder. In this situation, the command line helps you out. It will give you a tree-like representation of all the nested folders in that directory. Type this command and after pressing enter you’ll see the pictorial representation of all the folders.

How to save the command prompt’s output to a text file in windows

Overview of all the nested folders on a drive

You can also add “> c:\export.txt” after tree, to save the results in a text file that you can browse in your local storage.

How to save the command prompt’s output to a text file in windows

All the folders list is saved to the C drive.

10. View and delete Incognito history

You might know that your computer has a Domain Name System (DNS) which converts the site URL that you type in the browser address bar into an IP address equivalent to that site. So your Incognito history also gets saved in a DNS cache, sometimes referred to as a DNS resolver cache.

  • To view DNS cache type ipconfig /displaydns in the command line, and press enter and you will see all the sites with their IP addresses.

How to save the command prompt’s output to a text file in windows

DNS Cache consisting list of websites and their IP Addresses

  • To delete DNS cache type ipconfig /flushdns and your incognito history will be cleared.

How to save the command prompt’s output to a text file in windows

DNS Cache cleared

You can also checkout our detailed article about How to Check Incognito History and Delete it.

So these are five command tricks you need to know. Hope you find value from it. For more about such command tricks, visit this article about Useful CMD commands for daily use in Windows OS

There are a lot of things you can do in Command Prompt on Windows 10. Even so, this is one of the most underutilized apps; some users never even open it. The Command Prompt interface might look a bit intimidating due to command lines, specific syntax/code, and lack of clickable graphics interface.

How to save the command prompt’s output to a text file in windows

However, there is nothing to be afraid of, entering the wrong code/command is not going to mess up your PC, the command just won’t execute. You should know that certain actions are much faster via Command Prompt – file access, for example.

This article will explain all the necessary commands to open a file, close it, open a folder, and move to a folder

Opening a File

To access a file directly, Command Prompt requires you to enter the specific path. This means you need to enter the file name and its respective extension. Follow these steps:

  1. Type “Cmd” in Windows search and click on the app in results to run it.

How to save the command prompt’s output to a text file in windows
Navigate to the location of your file by typing the following into the command prompt window: Users\”Username”> cd C:\”Users\”Username”\”Location” In this example, the “Username” will be User and the “Location” will be desktop.

How to save the command prompt’s output to a text file in windows
Then type in the name and extension of the file you’re trying to open: “Filename.filetype.” In this example, the “Filename” will be screenshot and the “Filetype” will be .png

How to save the command prompt’s output to a text file in windows

Closing a File

The command to close a file is even simpler and it follows this syntax: taskkill /im “filename.filetype” /t. The example Filetype in this command will be “i_view64” and the Filetype will be “.exe”

How to save the command prompt’s output to a text file in windows

This command closes all the files that are open, even if they run in different apps like Microsoft Word or IrfanView. So you need to use it carefully, to avoid losing your progress or data.

How to Open a Folder

This command to open a folder follows this syntax: start %windir%explorer.exe path-to-folder. Here is an example of the exact path: start %windir%explorer.exeC:UsersLelaDesktop“.

How to save the command prompt’s output to a text file in windows

It’s important to note that the commands to open files and folders work without administrator rights. You should enclose the file or folder path in double quotes because they have specific names with spaces in between. On the other hand, if there are no spaces in the names the commands run without the double quotes.

Note: For grammar purposes, some example codes in this article have a full stop at the end of the sentence. When you use the command, omit the full stop.

Running Basic Programs

As indicated, you can run any program with simple commands and for this to work you might need administrative privileges. The syntax for running basic programs is: start program_name. Here is the list of commands you might find useful:

  1. start calc (Calculator)
  2. start notepad
  3. start explorer (File Explorer)
  4. start cmd (new Command Prompt window)
  5. start wmplayer (Windows Media Player)
  6. start mspaint (Paint)
  7. start taskmgr (Task Manager)
  8. start charmap (Character Map)

Hit Enter when you type the command and the given program should appear in a moment. You should make sure there is a space between the “start” part and the program name, but even so, some apps may not run. This usually means their folder is not in the search path of Command Prompt.

Command/Path-EndThisArticle

When all is said and done, opening a file via Command Prompt is much quicker than navigating through all the folders on your computer. You do need to know the exact file path/location, but you can easily find it with File Explorer on your computer. Have any experience, tips or questions related to opening files using the command prompt? Leave them in the comment section below.

Windows built-in command compact allows one to compress or un-compress files on a NTFS file system. Using this command we can set compression attributes on a directory also so that the new files added to the directory will be compressed automatically.Let’s see the syntax of the command ‘compact‘ with few examples.

Check the compression status of a file:

Compress a file from command line:

Uncompress a file:

To compress all the files in the current directory

To compress all the files in the current directory and also the sub directories and the files within them recursively

To un-compress all the files in the current directory

To un-compress all the files in the current directory and also in its sub directories:

how did you make the compression ratio to 8.0 to 1

can you show how to increase the max compression to a different amount?

Use ‘compact /?’ to find out more details on the command.
the compression ratio will depend on the file type I suspect, text compressing more than pictures for example.

but why i get that error:
‘compact’ n’est pas reconnu en tant que commande interne ou externe ….
.

Can we compress into .ZIP file in cmd without using powershell or vbscripts ?

I have used the same command it has run successfully but when i checked the size of my compressed file it shows same as previous

Where is my Compact file? I am not able to find it on my drive. Please guide.

Please everybody, be aware that this Compact is a bit like the old Drivespace in DOS: it does NOT create a NEW file, like a zip file, but it stores the same file, or the whole directory, in a compressed manner. In NTFS. Because NTFS has the ability to do that, and FAT / FAT32 cannot. Your Compressed file will only take less disk space when stored on that disk it was Compressed on. And I don’t know if that Compression attribute follows along when that file is copied to another (NTFS) disk.

It is possible to select so that compressed files show up in another colour in file explorer, for your convenience. And be aware that compaction ratios aren’t that impressive.

The practical use of Compress is less nowadays as we collect lots of images and sound and these can’t be compacted more, and Compress is a tradeoff between process speed and file size. Imagine compressing a database file? Great – it has to be unravelled and recompressed by Windows each time you make a record change.
Allegedly Compress works / (worked?) good with CAD programs where you have huge parts libraries with thousands of small component files.

In the best of worlds you can compress your Documents directory and %programfiles% to save disks space. But allegedly Compress interferes with windowsupdate.

Why are you trying to uncompress a .txt file.

How to save the command prompt’s output to a text file in windows

We all know how running a command in the Linux command line, the Terminal, results in the execution of the command and printing of the results in the Terminal itself. Sometimes, this immediate display of output is not enough, especially if we want to save the output for later use. Fortunately, the Linux bash and all operating system bash, for that matter, is equipped with the ability to print the output of a command to a specified file. In this article, we will deal with the following two tasks:

  • Saving Command Output to A File
  • Printing Output on Terminal and Saving it to a File

The commands mentioned in this article have been executed on an Ubuntu 18.04 LTS system.

Saving Command Output to A File

We will run a few examples where the output of the commands will be saved on the file name we specify.

Create New File/Replace existing file

If you want to save the output of a command to a new file or replace the contents of an already existing file with the output of the command, please use the following syntax:

For example, I will use the lscpu command(that displays system information) and then print its contents to the file named systeminformation.txt. This file does not already exist on my system.

When I access this file through the file manager, it looks like this:

Append Output to Existing File

If you want to save the output of a Linux command to a file without messing with its already existing contents, you can use the following syntax:

For example, the following command will append the result of the ls command at the end of my already existing file systeminformation.txt.

The following file that once contained only my system information now also contains the output of my ls command:

Printing Output on Terminal and Saving it to a File

You might have noticed that the commands that we mentioned above only save the output to the file without printing them on the Terminal itself. Use the following syntax if you want to view the output of the command on the Terminal as well:

For example, the text that we want to echo in the following image will now be echoed on the Terminal and also printed to the file myfile.txt.

These are the contents of the file generated through the command:

If you want to append the output of a command to an already existing file. Please follow this syntax:

For example, the following image shows how some more text will be echoed and then added to my already existing file:

This is how the file looks like now:

These output oriented text files that we generated through this article can be much more useful in some cases than the usual printing of output on the terminal. That’s how powerful the Ubuntu bash is!

  • ← Keep Your Clock Sync with Internet Time Servers in Ubuntu 18.04
  • Test your Internet Speed through Ubuntu Command Line →

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

How to save the command prompt’s output to a text file in windows

If you need to run commands like mkdir , ping , and netstat in Windows, you’ll need to open the Command Prompt program.

Turns out that there are a bunch of ways to do that. We’ll cover some of the most common ways to open Command Prompt in this article.

Note: While this article was written for Windows 10, some methods should be similar for earlier versions of Windows.

How to open Command Prompt from the Windows Start Menu

First, click the Start Menu button in the lower-left corner to open the start menu.

Scroll down to “Windows System” and click that to open a dropdown of different Windows programs. Then click “Command Prompt”:

How to save the command prompt’s output to a text file in windows

How to open Command Prompt with the search bar

One of the fastest ways to open Command Prompt is by using the search bar in the Windows 10 Taskbar.

Just type “cmd” into the search bar and click on “Command Prompt”:

How to save the command prompt’s output to a text file in windows

How to open Command Prompt from the Run program

Windows 10 has another program called Run that lets you, well, run other programs. You can also do things like open folders and files, but that’s outside the scope of this tutorial.

To open Run, you can open the Start Menu and find it under “Windows System”. You could also type “run” in the search box and find it that way.

But the fastest way to open Run is with the shortcut Windows Key + R.

Then, once the Run window is open, just type in “cmd” and press “OK” to open Command Prompt:

How to save the command prompt’s output to a text file in windows

How to open Command Prompt as an administrator

Some commands like powercfg or chkdsk require that you open Command Prompt as an administrator. This will give you elevated access for whatever commands you run.

To open Command Prompt as an administrator, find Command Prompt using any of the methods described earlier.

Then, right click on “Command Prompt” and click “Run as administrator”:

How to save the command prompt’s output to a text file in windows

You may need to hover over “More” depending on the method you used to find the Command Prompt program.

Also, you may see a “User Account Control” window pop up with the message “Do you want to allow this app to make changes to your device?” Just click “Yes” to continue.

After this, you should see a Command Prompt window with “Administrator: Command Prompt” across the top:

How to save the command prompt’s output to a text file in windows

Alternatively, you could open Command Prompt as a normal user, type in a command, and then press Ctrl + Shift + Enter to run that command as an administrator.

Note: While you should always be careful about what commands you run in Command Prompt or any other command line program, be especially mindful about what you run as an administrator. One wrong command could delete important system files and ruin your installation of Windows.

In summary

These are just some of the many ways to open Command Prompt in Windows. Go with whatever works best for you and run commands to your heart’s content.

But please, before you run any command, double check that everything is correct, especially if you opened Command Prompt as an administrator. Speaking from experience, a few extra seconds of caution could save you hours of reinstallation.

And with that, go forth and (safely) run all the commands.

Read more posts by this author.

If you read this far, tweet to the author to show them you care. Tweet a thanks

Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

freeCodeCamp is a donor-supported tax-exempt 501(c)(3) nonprofit organization (United States Federal Tax Identification Number: 82-0779546)

Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons – all freely available to the public. We also have thousands of freeCodeCamp study groups around the world.

Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff.

It is also possible to think of it as a temporary but direct link between two or more processes, commands, or programs. Filters are those command-line programs that perform the additional processing.

This direct connection between processes or commands allows them to execute and pass the data between them simultaneously without facing the trouble of checking the display screen or temporary text files. In the pipeline, the flow of the data is from left to right which declares pipes are unidirectional. Now, let’s check out some practical examples of using pipes in Linux.

Piping the List of Files and Directories:

In the first example, we have illustrated how you can use the pipe command for passing the list of directories and file as an “input” to more commands.

How to save the command prompt’s output to a text file in windows

Here, the output of “ls” is considered as input by the “more” command. At a time, the output of the ls command is shown on screen as a result of this instruction. The pipe provides the container capability for receiving the ls command output and passing it to more commands as input.

As main memory performs the pipe implementation, this command does not utilize the disc for creating a link between ls -l standard output to the standard input of more command. The above command is analogous to the following command series in terms of operators of Input/Output redirection.

How to save the command prompt’s output to a text file in windows

Check out the “temp” file content manually.

How to save the command prompt’s output to a text file in windows

How to save the command prompt’s output to a text file in windows

Sort and Printing Unique Values Using Pipes:

Now, we will see a pipe usage example for sorting a file content and printing its unique values. For this purpose, we will combine the “sort” and “uniq” commands with a pipe. But first select any file containing numeric data, in our case we have the “record.txt” file.

Write out the below-given command so that before pipeline processing, you have a clear idea about the file data.

How to save the command prompt’s output to a text file in windows

Now, the execution of the below-given command will sort the file data, while displaying the unique values in the terminal.

How to save the command prompt’s output to a text file in windows

Pipe Usage with Head and Tail Commands

You can also use “head” and “tail” commands for printing out lines from a file in a specific range.

The execution process of this command will select the first seven lines of “samplefile” as an input and will pass that to the tail command. The tail command will retrieve the last 5 lines from “samplefile” and will print them out in the terminal. The flow between command execution is all because of pipes.

How to save the command prompt’s output to a text file in windows

Matching a Specific Pattern in Matching Files Using Pipes

Pipes can be used for finding files with a specific extension in the extracted list of ls command.

How to save the command prompt’s output to a text file in windows

How to save the command prompt’s output to a text file in windows

Pipe Command in Combination with “grep”, “tee”, and “wc”

This command will select the “Alex” from “record.txt” file, and in the terminal, it will print out the total number of occurrences of the pattern “Alex”. Here, pipe combined “cat”, “grep”, “tee”, and “wc” commands.

How to save the command prompt’s output to a text file in windows

Conclusion:

A pipe is a command that is utilized by most Linux users for redirecting the output of a command to any file. The pipe character ‘|’ can be used to accomplish a direct connection between the output of one command as an input of the other one. In this post, we have seen various methods of piping the output of a command to the terminal and files.

About the author

How to save the command prompt’s output to a text file in windows

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.

By Alisa | Follow | Last Updated January 11, 2022

Summary :

How to save the command prompt’s output to a text file in windows

Wonder how to open a file cmd or how to open a folder in Command Prompt on Windows 10? This tutorial provides a step-by-step guide. Also, if you can’t find some files or folders in Windows 10, or some files are unexpectedly lost in your Windows 10 computer, MiniTool free data recovery software for Windows 10/8/7 can help you easily recover lost files.

You can also open files from Command Prompt. Wonder how to open a file or folder in Command Prompt on Windows 10? Check the step-by-step guide in this tutorial.

How to Open a File CMD Windows 10 in 2 Steps

Step 1 – Open Command Prompt

You can press Windows + R keys on the keyboard to open Windows Run dialog. Then type cmd in the Run box. If you want to run Command Prompt as Administrator, you need to press Ctrl + Shift + Enter keys at the same time.

Alternatively, you can also click Start or Search box in Windows 10, and type cmd or command prompt. Right-click the Command Prompt app in the list and choose Run as administrator.

Step 2 – Open Files from Command Prompt

Normally you have two ways to open a file using cmd. One is to move the folder that the file is in, the other is to open the files directly in Command Prompt.

Method 1. How to open a file with cmd by moving to the folder firstly

  • You can use the cd command to move to the exact folder the file lies in. For instance, cd C:\Users\mini\Desktop.
  • After you are in the correct folder path, you can type the name of the file with its extension, e.g. “travel.png”, and hit Enter button to open it.

How to save the command prompt’s output to a text file in windows

How to save the command prompt’s output to a text file in windows

How to stop Windows 11 update? This post provides 5 solutions to let you disable automatic updates on Windows 11. Check the step-by-step guide.

Method 2. How to open a file using cmd directly

You can also choose to open files from Command Prompt on Windows 10 directly, instead of going to the folder path. You can input the full path, file name and its file extension to open the target file, e.g. “C:\Users\mini\Desktop\travel.png”.

How to save the command prompt’s output to a text file in windows

You can also freely specify an app to open the file. You need to type the whole path of the app ahead of the path of the file, for example, “%windir%\system32\mspaint.exe” “C:\Users\mini\Desktop\travel.png”. Press Enter to open the file using CMD.

How to save the command prompt’s output to a text file in windows

If you forgot Windows 11 password, you can check the 6 solutions in this post to reset/bypass Windows 11 password. Also learn how to change Windows 11 password.

How to Open a Folder in Command Prompt Windows 10

You can also open a folder from Command Prompt with the command line below.

After you enter into Command Prompt window by following the operation above, you can open a folder in File Explorer in Command Prompt. The command line can be like this, start %windir%\explorer.exe “C:\Users\mini\Desktop”.

How to save the command prompt’s output to a text file in windows

Tip: Need to mention that you need to enclose the path of a file or folder in double quotation marks, since some folder or files names have spaces in them.

>> Quick Video Guide:

To Recover Unexpectedly Lost Files or Folders in Windows 10

Sometimes you may suffer unexpected data loss in Windows 10 due to various reasons, e.g. system crash, Blue Screen error (e.g. Bad Pool Caller BSOD error), power outage, malware/virus infection, hard drive failure, etc. To easily recover lost data for free, you can choose the best free data recovery software to realize it.

MiniTool Power Data Recovery, a 100% clean and free data recovery software for Windows 10/8/7, enables you to easily recover mistakenly deleted files or lost files from computer local drive, external hard drive, SSD drive, USB drive (pen drive data recovery), SD card, and more.

How to save the command prompt’s output to a text file in windows

Windows 11 won’t update? Check the 8 solutions in this post to troubleshoot Windows 11 update problems and can’t update Windows 11 issue.

  • Facebook
  • Twitter
  • Linkedin
  • Reddit

ABOUT THE AUTHOR

How to save the command prompt’s output to a text file in windows

Position: Columnist

Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.