1.

Solve : Running ping from a batch file?

Answer»

First, to all who contributed to the batch file and command pages, a big THANK YOU! No programming knowledge at all here, but have made a number of batch scripts to automate things like DATA backups and disk cleanups. Everyone *says* back up your stuff frequently (the puter might not boot next time), but few do. Two clicks on a batch, and all the good stuff is copied to a flash drive in seconds. ECHO: THANK YOU!

OK, time to move past xcopy, del, and rd. XP SP2 preloaded by OEM (who strongly advised *not* to install SP3; not here to discuss that, thanks), both Home and Pro, on laptops with wireless router to high-speed cable modem. Using CMD.exe.

Situation: Sometimes, a Web page will stop responding, as we all know. Lots of reasons. But every once in a while, the reason is that the connection has been dropped, whether by the ISP, the modem, or the router. The *connection between machine and router* never goes down, so it's SOMEWHERE between the router and the Web. Quickest diagnostic is to ping example.com. If it works, it's probably the web server, etc. If not, then either the modem or router has dropped the connection. Reboot them, and all is well.

Here's the problem: You guys and gals have me so spoiled , I don't want to open a command prompt and type all that, although the typing can be automated by auto-text tools. And I'm too lazy to put down the laptop and go into another room to look at the modem and router. Hey, that's part of the goodies of laptops! I'd like a batch file that when 2-clicked, runs the command ping www.example.com. Default parameters are fine. It's only four packets.

Tried with just ping etc., and also with cmd /K for a new window. Allowed TCP/IP Ping command in firewall. What happens: cmd window opens, but it just keeps repeating the command infinitely, and very fast, so I have to close the window. No actual pinging.

Ball in your court. And thanks in advance! (Have I said "thank you" yet?)Your questioning style is so very annoying. Could you try cutting out all this Hey! Yee-har! stuff? Also, as you admit, you are being lazy. Why should we do all your thinking for you? Have you tried writing the batch script yourself? Did you even think of telling us what you have tried already?

Code: [Select]@echo off
ping www.example.com
pause
Wow, you guys are harsh. First post, the user thanks everyone. I've been a volunteer mod at other forums, and it's always nice when someone takes the time to show some appreciation. I don't think I've ever been offended by someone thanking us *too* much. Strange.

Annoying style? People who curse or are snotty are more offensive than those who maybe are a little to friendly or chatty to suit your tastes. I checked the Registration agreement, and there was nothing about being too friendly. Maybe you should amend that.

Quote from: Salmon Trout

Why should we do all your thinking for you? Have you tried writing the batch script yourself? Did you even think of telling us what you have tried already?

Did you not *read* the user's post?

Quote from: Bat Mastersome
Tried with just ping etc., and also with cmd /k for a new window.

He is saying that he already tried the batch file with exactly that: ping www.example.com, which BC_Programmer later suggested. And that he also tried with cmd /k ping www.example.com. And he gave you the result:

Quote from: Bat Mastersome
What happens: cmd window opens, but it just keeps repeating the command infinitely, and very fast, so I have to close the window. No actual pinging.
Did you not *read* that?

Quote from: Salmon Trout
Could you try cutting out all this Hey! Yee-har! stuff?

I searched the OP, and didn't find any use of "Yee-har". So now it's Salmon Trout who's being sarcastic and snotty. Maybe he should be banned.

Speaking of which: *Banned* on the first post, because you don't like his style of writing? Not even a warning or a request to phrase differently? Guess you should have an exact format posted, fill in the blanks, the way you like it, since anything else is apparently unacceptable. We banned people for spam, usually after one warning unless really bad; scamware or malware links immediately; profanity, usually after a warning unless really bad. *Never* because their style of questioning was "personally annoying". 7 billion people in the world, they're not all going to talk and write exactly alike, you know. Saw others here banned on first post because of some little nit. Someone asks you to do their homework or whatever? Point them to the rule about it, matter-of-factly, and keep them as a member for life, instead of banned for life for one mistake. Sheesh.

Wikipedia has among its basic tenets: "Don't bite the newcomer". You guys sure took a GREAT chomp out of this one. Nice job of reinforcing the stereotype of computer people as being rigid, humorless geeks. Oh, and don't bother banning me - I won't come back here *ever*, I promise. And neither will my evil twin, the OP. Have a nice day.

P. S. Since you guys didn't care to answer the question of why the ping command was being repeated endlessly, it was solved another way: auto-text tool (won't spam the name of it, even though it's total freeware). One click on Start, one on shortcut to cmd, one trigger letter ("p") which auto-types the desired command, (enter). Four keystrokes instead of two, and no having to deal with mini-dictators who do on the Web what they can't do in real life. Sad. Good luck. What's all this about people being "banned"? The OP has not been banned that I know of, but then I am not a moderator, just an ordinary member who gave his own personal, non-official opinion. If the OP was indeed banned, it must have been for something else that i don't know about, something more serious than a posting style that I didn't like!


The OP never was and is not banned...
The person who was and had his Posts removed was...maybe that's who former mod is referring to...we all know who that was...
Thanks former mod on all the good advice on running a Forum.
Say hi to Bill for us.Here is a great Network Connection Tester I came across. hope it helps
Code: [Select]@echo off
ECHO Checking connection, please wait...
PING -n 1 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS
IF ERRORLEVEL 1 goto :TRYAGAIN

:TRYAGAIN
ECHO FAILURE!
ECHO Let me try a bit more, please wait...
@echo off
PING -n 3 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS2
IF ERRORLEVEL 1 goto :TRYIP

:TRYIP
ECHO FAILURE!
ECHO Checking DNS...
ECHO Lets try by IP address...
@echo off
ping -n 1 216.239.37.99|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESSDNS
IF ERRORLEVEL 1 goto :TRYROUTER

:TRYROUTER
ECHO FAILURE!
ECHO Lets try pinging the router....
ping -n 2 192.168.0.1|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :ROUTERSUCCESS
IF ERRORLEVEL 1 goto :NETDOWN

:ROUTERSUCCESS
ECHO It appears that you can reach the router, but internet is unreachable.
goto :FAILURE

:NETDOWN
ECHO FAILURE!
ECHO It appears that you having network issues, the router cannot be reached.
goto :FAILURE

:SUCCESSDNS
ECHO It appears that you are having DNS issues.
goto :FAILURE

:SUCCESS
ECHO You have an active Internet connection
pause
goto END

:SUCCESS2
ECHO You have an active internet connection but some packet loss was detected.
pause
goto :END

:FAILURE
ECHO You do not have an active Internet connection
pause
goto :END

:END



Discussion

No Comment Found