Advertisement
J2897

Internet-up Alerter

Dec 16th, 2014
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.67 KB | None | 0 0
  1. :: Released under the GNU General Public License version 3 by J2897.
  2.  
  3. @echo OFF
  4. title Internet-up Alerter
  5. pushd "%~dp0"
  6. setlocal
  7.  
  8. REM #################### README #################### > BEGIN
  9. :: Filename:    Internet-up Alerter.bat
  10. :: Contact:     https://pastebin.com/message_compose?to=J2897
  11. ::
  12. :: This script will attempt to ping a target address. If the ping is successful,
  13. :: it will look for the 64-Bit version of VLC; failing that, it will look for the
  14. :: 32-Bit version of VLC; and failing that, it will play the audio file just once
  15. :: from your computer's default audio player. If you have VLC installed, the
  16. :: audio file will repeat, over and over again, until you stop it.
  17. REM #################### README #################### > END
  18.  
  19. set "TARGET=google.co.uk"
  20. set "DELAY=30"
  21. set "VLC32=%SYSTEMDRIVE%\Program Files\VideoLAN\VLC\vlc.exe"
  22. set "VLC64=%SYSTEMDRIVE%\Program Files (x86)\VideoLAN\VLC\vlc.exe"
  23. set "OPTIONS=--repeat"
  24. set "AUDIO_FILE=%WINDIR%\Media\tada.wav"
  25.  
  26. :try_again
  27. cls
  28. echo ISP problems? This will alert you when your internet is back up. It will try to
  29. echo ping '%TARGET%' every %DELAY% seconds.
  30. echo.
  31. echo When a ping rebounds, this audio file will start:
  32. echo %AUDIO_FILE%
  33.  
  34. ping -n 1 "%TARGET%" >nul
  35. if %ERRORLEVEL% EQU 0 (
  36.     if exist "%VLC64%" (
  37.         REM Use the 64-Bit version of VLC in repeat mode.
  38.         start "" "%VLC64%" %OPTIONS% "%AUDIO_FILE%"
  39.     ) else (
  40.         if exist "%VLC32%" (
  41.             REM Use the 32-Bit version of VLC in repeat mode.
  42.             start "" "%VLC32%" %OPTIONS% "%AUDIO_FILE%"
  43.         ) else (
  44.             REM Resort to the default audio player.
  45.             start "" "%AUDIO_FILE%"
  46.         )
  47.     )
  48.     endlocal
  49.     popd
  50.     goto :EOF
  51. )
  52.  
  53. timeout /t %DELAY% /nobreak
  54. goto :try_again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement