Windows Tutorials

How To Ping With Date and Time To TXT File Using CMD

There are occasions where you will need to know How To Ping With Date and Time To TXT File Using CMD and a few Windows Ping commands can help. This will use a provide a date and a timestamp the result of each ping, with a bit of effort you can get it to do that. It’s quite useful if you specifically need to use the Windows Ping command. 

ping -t patrickdomingues.com|cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 patrickdomingues.com>nul" >C:\ping\pingtest.txt

Ping With Data and Time Using CMD

The above will continuously ping the address with a time and date to a output log file which in this case is called pingtest.txt , press Ctrl+C to end the session. If you do not need an output file remove the redirection to an output file string if you want to show the results in the console window.

5 Comments

  1. If I run this command from cmd it is working but in a batch i get the following error C:\Temp>ping -t patrickdomingues.com | cmd /q /v /c “(pause&pause)>nul & for /l \temp\pingtest.txt
    \temp\pingtest.txt was unexpected at this time.

  2. Thank a lot, Patrick.
    This command will result in more request timeouts than just using ping – t. Even the single command “ping -t destination” does not have a request timeout. Could you help me to understand more about what happened to cause the request timeout?

    1. When discussing the usage of ping commands, it’s important to understand how they operate and why request timeouts may occur.

      The ping command is a network utility used to test the reachability of a host on an Internet Protocol (IP) network. It measures the round-trip time for messages sent from the originating host to a destination computer.

      Ping -t: This command sends ping requests continuously to the host until it is manually stopped. It’s often used for diagnosing network issues. Since it doesn’t stop until the user intervenes, it usually doesn’t have a request timeout by default.

      Request Timeout: This occurs when a ping request is sent to the destination host, but there is no response within the expected time frame. Timeouts can happen for various reasons: the destination host might be down, there could be network issues, or the host could be behind a firewall that’s blocking ICMP packets (used by ping).

      Now, regarding your specific situation:

      If you’re experiencing more request timeouts with a command other than ping -t, it could be due to the network conditions between your computer and the destination, or specific settings in the command you are using.

      Change the destinations, Run multiple pings to save to text file to reference back to, ping google, ping your firewall, ping another computer or server. This will help you detect where the packets timeout, if its all 3 pings dropping then you do have a bigger issue. If you are on wifi there are other things to take into account.

Leave a Comment

Stay Informed

Receive instant notifications when new content is released.