I'm wondering if I could make a batch file that checks internet connection
If connection is successful then say Internet connected
If connection unsuccessful then say Internet disconnected
Thanks
-SR
Internet ping test + say results
Moderator: DosItHelp
Re: Internet ping test + say results
Easiest way is to ping a common web site, such as google.com
That doesn't protect you from getting a false result if google is down though. Unlikely but still possible.
Steffen
Code: Select all
@echo off &setlocal
>nul ping google.com -n 1
if errorlevel 1 (echo Internet disconnected) else echo Internet connected
pause
Steffen
Re: Internet ping test + say results
Could it be possible to add this script 3 times with 3 different sites as to mak sure that the ping results are correct? Sometimes, there might be issues with one site that messes up your ping data, but basing the results on different sites (preferably non affiliated with Google, if you use google.com as your first "target") would eliminate that risk.
-
- Posts: 2
- Joined: 26 Nov 2019 09:05
Re: Internet ping test + say results
Can I get it to speak at all?
Re: Internet ping test + say results
Sure. Just ping 3 sites and if you get errorlevel 0 for one of them you may assume that you're connected. Perhaps you want to contribute the code for that?
Oh, you literally talked about speaking. Well, not using Batch allone. A JScript hybrid should work though.
*.bat
Code: Select all
@if (0)==(0) echo off &setlocal
>nul ping google.com -n 1
if errorlevel 1 (set "msg=Internet disconnected") else set "msg=Internet connected"
cscript //nologo //e:jscript "%~fs0" "%msg%"
goto :eof @end
WScript.CreateObject('SAPI.SpVoice').Speak(WScript.Arguments(0));