Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Windows Batch & VB Script: Report ping results into a txt file.

Hello experts, some users report bad performance of application that manage my team. In order to launch an action plan I would like to report ping information in a txt file in order to discard network issues.
The idea is that user run bat or vbscript and then a txt file will be generated with ping results.
In bat & vbs file I should be able to report:
1-Adress that I want to ping
2-Time scale and frame option in order to run ping during a certain period of time.

If you have some feedback or ideas about this please don’t hesitate to help me.
Avatar of Anthony Janson
Anthony Janson
Flag of Hungary image

Time frame and scale is hard to implement in a batch script, but you can do a one-liner command in batch that will do the amount of hops like this:

ping -n x www.experts-exchange.com > C:\PingResult.txt

Open in new window


Replace the x with the amount of tries it should do and the website with your DNS name or IP address.

If you want to do it through Task Scheduler where you specify the time, you can change it to the below where you kill off the task after a certain time as -t will never quit on it's own.

ping -t www.experts-exchange.com > C:\PingResult.txt

Open in new window


You can also do it to a network path, provided that the account has access to write, like this.

ping -n 10 www.experts-exchange.com > "\\server1\writelogshere$\%HOSTNAME%\%DATE% PingResult.txt"

Open in new window


%HOSTNAME% and %DATE% are variables already stored in the CMD shell, but it will take the local date on the system. So if you have multiple languages, it may show different dates.
Avatar of Bill Prew
Bill Prew

Can you expand more on how you intend to use this?  Will it be run by the user at their computer?  Or from your computer?

Will you be pinging the server where the application resides?

Is this a web application, or client servers, or just a shared database?

Also, ping is a fairly crude tool, and not sure you will learn a ton.  If it comes back very fast at the time they are seeing slow application performance, then that helps you focus on things on the server, like CPU usage, disk I/O, contention, etc.  But if ping performs slow, then not sure that tells you a lot.  There are a lot of variables that could affect the ping results...


»bp
Avatar of Luis Diaz

ASKER

Can you expand more on how you intend to use this?  
Users located in specific site complain about performance issues. I would like to discard network issues as an immediate action. Thought ping is not a full indicator it will provide a picture about the issue.

Will it be run by the user at their computer?  Or from your computer?
It will be run by the user at the computer

Will you be pinging the server where the application resides?
Yes

Is this a web application, or client servers, or just a shared database?
Web application

Also, ping is a fairly crude tool, and not sure you will learn a ton.  If it comes back very fast at the time they are seeing slow application performance, then that helps you focus on things on the server, like CPU usage, disk I/O, contention, etc.  But if ping performs slow, then not sure that tells you a lot.  There are a lot of variables that could affect the ping results.
I understand, however ping is the initial action to take.
If you can provide me your expertise feedback and how should I proceed after the ping execution it would be great. I am not asking a full strategy but just foundamental thinks that I should check such as network, computer info of the pc etc…
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for your feedback.
To properly resolve this issue I will adopt a benchmark approach. I will try to ping on the behalf of contributor + on the behalf of other contributors in the same site + on the behalf of of other contributors in other sites of the same country and in other countries. If I see that ping results is different between contributors located in the same date I can assume issue can come from contributor who raised the issue. If ping result is the same for all contributors in the same site but significantly different from contributors from other sites I can assume that there is a network issue related to this site.

I know that ping is not the most reliable tool however it will allows me in a first place to decline or push ahead some assumptions.
If you have another ideas, please let me know.
Thank you again for your help.