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.
LVL 1
LD16Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony JansonSystems EngineerCommented:
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.
Bill PrewIT / Software Engineering ConsultantCommented:
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
LD16Author Commented:
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…
Bill PrewIT / Software Engineering ConsultantCommented:
You probably want to use a payload for the ping (-l option)  that simulates the number of characters that the application typically sends.

Since you are trying to rule out network issues, then you can only make that assumption if the ping comes back "quickly", whatever you decide that is.

If the ping is slow then that doesn't mean the network is the problem, the local PC could be overloaded, the web server could be, etc.  In cases of slow ping performance the network could be a contributor, but so could other things, and I don't think ping will shine light on that.  You would then need to dig deeper and look at resource usage on the computers involved, as well as some more detailed network stats.


»bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LD16Author Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.