How to Ping with Timestamp from CMD in Windows [7 Ways]
When it comes to troubleshooting a network or internet connection there are several possible ways to do it. One of the simplest is to use the built-in Windows Ping utility to ping another computer because it can quickly help determine if there is a connection between the host and a remote computer. Not only can the Ping command help you identify local network issues, but it can also be used to test the uptime of a remote IP address, server or website.
Ping does the job it’s designed for and is run from the command line or batch scripts, so you have to supply a few arguments to tailor it to your needs. Although it’s powerful enough for most uses, one option missing from the Ping tool is the ability to include a time and date so you can see the exact point in time the ping response was received. That’s useful if you want to continuously ping over a period of time.
In addition to a timestamp, it’s also useful to be able to continuously ping for reliability over a period of time and optionally send the results to a text file for logging purposes. Here we show you 7 ways to timestamp pings as well as sending a continuous set of ping results to a text file. Make sure to run Command Prompt or batch files as Administrator to avoid issues as some tools require it.
1. hrPinghrPing is by cFos Software who also develop the cFosSpeed internet accelerator application. The hrPing tool itself is one of the most advanced of its type and allows you to configure just about anything you want with regards to what you ping, how often you ping it and when. There are around 40 different command line arguments available so reading the documentation is recommended for more advanced usage.
Luckily you only need a few of the available arguments to ping with a timestamp and optionally send the results to a text file. Use -t to loop the ping until you manually stop it, -T adds the time and date stamp while -F [filename] allows saving the output to a text file (include -q to output only to file).
hrping -t -T -F D:\pingtest.txt raymond.cc
To ping a specific number of times instead of continuously, substitute -t for -n [number]. Also, you can use -s [milliseconds] to reduce the ping frequency from half a second to something a bit slower. An additional argument of -gg will open a separate window with a small graph of ping response times (pictured above), useful if you have a particular interest in the speed of the ping responses.
2. PingWiz
For ease of use, it doesn’t get much simpler than PingWiz because it’s like a cut-down version of the Windows ping command that timestamps each ping request automatically without additional arguments.
Simply use pingwiz [hostname] and it will add the time and date with pinging the host four times. Adding /t will loop the pings continuously until you press Ctrl+C or /n:[number] will ping the specified number of times. A manual redirection to an output file is required if you want to send the ping results to a log file.
pingwiz raymond.cc /t >C:\pingtest.txt
There are only two other commands available in PingWiz in addition to those above, the ping timeout in seconds (/w) and the number of bytes to send (/b). Unlike hrPING, this tool will not show ping results in the console window and redirect to a file at the same time.
3. PingInfoView
PingInfoView by Nirsoft is a little different to the other tools because it works from a graphical user interface. This makes it easy to spot ping errors more quickly if you are actively monitoring and watching for issues because they will show up in the user interface as red entries. PingInfoView does have some command line options but they are to control ping rates and file saving in the user interface.
On launch, PingInfoView will popup a window where you can add one or a number of addresses to monitor, the ping timeout and the repeat rate (default is to ping every 5 seconds). Press OK and the main window will appear. The upper pane is the monitored hosts list with statistics about the ping results like success/fail rates, min/max/average times and succeed/fail times.
Click on a host in the upper pane to show the individual time stamped ping results at the bottom as they come in. When you have finished monitoring press the Stop button on the toolbar. The lower pane results can be saved to a text file, click on any entry and press Ctrl+A to highlight everything, right click and choose “Save Selected Items”, then save as a tabbed text, delimited text or HTML file.
4. PowerPing
PowerPing is an open source tool hosted on GitHub. What sets this tool apart from other command line programs is there’s a splash of color in the ping results so you can more easily spot successes and failures. There are also around 40 commands available to control the pinging process and perform a few extra functions.
Typing PowerPing and using just the hostname will perform a standard five pings, including –t will make it continuous. The all important timestamp option is added with –ts which will put the time at the end of the line. There is no date in PowerPing’s timestamp so you may have to try another tool if that is something you need. To adjust the ping interval, use –in [milliseconds].
PowerPing –t –ts –in 2000 raymond.cc
If you want a more visual display, PowerPing has a graph option (–g) that will show in the console window instead of the text. There’s also a few general network features such as getting the location for an address, a whois lookup for an address and a whoami for the current host. You can also turn the colors off or enable a beep for timeouts. To send the output to a file, use the standard redirection method of >filename.
5. Bping
By default, Bping will give an audible beep or play a custom WAV file every time it pings and receives a reply. However, this option can be changed so Bping only beeps on a failure. If the Bping output is being redirected to a file, it can be left to beep or you can turn it off. It can also scan for and show other computers on the network with the option to show freely available IP addresses.
To add a timestamp to the command use the -u argument, -q will completely disable the beep if you find it annoying. Pinging will be continuous by default unless you use -n=number. Bping will ping Google DNS (8.8.8.8) if you don’t supply an address or hostname. As there is no command to output to file, redirect the results using >filename or >>filename to append to an existing file.
bping raymond.cc -u -q >C:\pingtest.text
Some other useful commands are -d which will only beep if the ping fails, -s which will scan the local network for devices, -a will show all available addresses on the network, and -c will add a count number to each ping. If you don’t use the number option the Bping command will have to be exited from the command line with Ctrl+C because it will continuously ping until you exit the program.
6. Windows Ping Command
Although the Windows Ping command has no built-in function to date and 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. The following was found on StackOverflow and looks complicated but seems to work quite well.
ping -t raymond.cc|cmd /q /v /c “(pause&pause)>nul & for /l %a in () do (set /p “data=” && echo(!date! !time! !data!)&ping -n 2 raymond.cc>nul” >C:\pingtest.txt
The above will continuously ping the address with a time and date and an output log file, press Ctrl+C to end the session. If you wish to add the line to a batch script substitute the “%a” for “%%a” in the middle of the command. There are of course variations of inserting the time and date into the Windows Ping, feel free to share them in the comments. Remove the redirection to an output file if you want to show the results in the console window.
7. Ping From PowerShell
There are some dedicated PowerShell commands for pinging remote computers like Test-Connection and Test-NetConnection, but the standard Ping command also works as normal. As with Command Prompt, PowerShell requires you to manually insert a timestamp.
Test-Connection -count 999999999 -delay 2 raymond.cc | select @{n=’Date/Time’;e={Get-Date}},Address , IPv4Address ,ResponseTime >C:\pingtest.txt
As Test-Connection does not have an infinite loop switch we have to set a large count time. An optional delay of two seconds between pings helps extend the time even further. For using the Ping command:
Ping.exe -t raymond.cc | ForEach {“{0} – {1}” -f (Get-Date),$_} >C:\pingtest.txt
The above does pretty much the same as Ping from Command Prompt in method six. One of the advantages PowerShell has over Command Prompt is the ability to send the output in two different directions at once. That gives you the option to view the ping results in the console window and output to a file at the same time.
Ping.exe -t raymond.cc | ForEach {“{0} – {1}” -f (Get-Date),$_} | Tee C:\pingtest.txt
All you have to do is replace the redirect arrow with a pipe “|” and the Tee (or Tee-Object) command. This also works with other commands in PowerShell and is useful if you want to log and view console output at the same time.
Nice article..
#6 is great but I had to make another change for it to work in a batch file. I had to delete the “ and replace with new double quotation marks. I guess the HTML adds formatting so the command cannot just be copied and pasted into a text file.
Love this post man, awesome tools, a question, with HRPING how do you open the graphics window?
Hi Nelson. You need to unzip the hrping.exe and grping.exe files in the same folder and use -g at the end of the command line.
This is a great article, however, when stopping either the command prompt ping in section 6 or the powershell ping in section 7, how can a ping summary be obtained? A normal ‘ping -t ‘ when terminated with CTRL+C will print a summary at the end. By timestamping the individual pings, that summary is not given when the command is terminated.
Hi, in the part 7, ping from prowershell, where does the ‘n’ and ‘e’ come from?
select @{n=’Date/Time’;e={Get-Date}}
I mean, if I change those two characters the command doesn’t work.
Thanx!
n gives the name (Date/Time) to the expression Get-Date (e). This is what shows the time and date on the line. You cannot change n or e as they are built-in parameters of Select, however, you can use the full titles of name or expression instead.
select @{name=’Date/Time’;expression={Get-Date}}
Windows Ping Command is not getting the output
Add a -t before the |cmd and it will then start logging.
Thank you the powershell option with Tee to have 2 outputs is working perfectly
Glad you found it useful. :)
#6 is awesome. Don’t ever run a ping cmd without it again!
Great work!
but PingInfoView is not reliable. Normal ping running in parallel showed no interruptions, but PingInfoView was always switching from green to red and back again. Response times were far below the limit.
6th option of ping with timestamp through windows ping command, helped a lot.
Thank you
Nice, but it would be nice if it output to screen AND text file, like your example shows. I only get it to text file.
If you notice, the command used in the image doesn’t redirect to a file, which is why I got the output. As far as I know, it’s not possible to get output in the console and write it to a file at the same time for this type of command.
It can be done through PowerShell though…
Last one I suppose, as the same happened for me
Excellent been looking for something like this for weeks!
Great job.
Thanks & it is great – 6
6 is perfect. I solved some problems that I had for years
great stuff! may i ask for help how to prefex hostname in the output which querying service status
use -a after ping like cmd : ping -a *.*.*.* -t
You will get the host name
hi its suberb. can I create a batch file to run point no 6 command for multiple ip
Thank you… point no. 6 saved my life… :)
Number 6 saved my life :)
Great job! I love the built in cmd, way number 6th.
Great Tips for me, I made the command as expected, thank you
netmon nullsoft
Great post easy to follow.
Superb.. very helpful..
This was a lifesaver, thank you.
Great Stuff
Good stuff mate. Thanks
Thanks :) You helped me.
Well, hrPing is not doubt good comparing to Windows Command Prompt but it have a big drawback of causing High CPU Usage nearly 90-100%. Due to this other programs performance are effected and work slowly.
Nice ping tool. But I personally have been using fping by kwakkelflap.
Bit “above my pay grade” this – but a good find and have added it to my toolkit with the explanatory text from their website. Thanks Raymond.
awesome post, thanks for the tips
Jason admires this blog. Why didn’t I find it before?
At last – now we can all have a Machine that goes “Ping”! :-P
that is a nice find Raymond.