Windows 10

Batch File To Write Ping Results To a Text File

In this tutorial, we are going to see how to write ping results to a text file by using the Redirection operator. The batch file contains a series of DOS (Disk Operating System) instructions. It allows triggering the execution of commands found in this file.
 

Batch File To Write Ping Results To a Text File

The following example write the results of ping 192.168.0.1 -n 4 to “file.txt”:
 

 

@echo off

ping 192.168.0.1 -n 4 > file.txt

Output:
 

  • The > operator is used to overwrite any file that already exists with new content.
  • The >> operator is used to append to the text file (add to), instead of overwriting it.

 

Leave a Reply

Your email address will not be published. Required fields are marked *