Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Released under the GNU General Public License version 3 by J2897.
- @echo OFF
- title Internet-up Alerter
- pushd "%~dp0"
- setlocal
- REM #################### README #################### > BEGIN
- :: Filename: Internet-up Alerter.bat
- :: Contact: https://pastebin.com/message_compose?to=J2897
- ::
- :: This script will attempt to ping a target address. If the ping is successful,
- :: it will look for the 64-Bit version of VLC; failing that, it will look for the
- :: 32-Bit version of VLC; and failing that, it will play the audio file just once
- :: from your computer's default audio player. If you have VLC installed, the
- :: audio file will repeat, over and over again, until you stop it.
- REM #################### README #################### > END
- set "TARGET=google.co.uk"
- set "DELAY=30"
- set "VLC32=%SYSTEMDRIVE%\Program Files\VideoLAN\VLC\vlc.exe"
- set "VLC64=%SYSTEMDRIVE%\Program Files (x86)\VideoLAN\VLC\vlc.exe"
- set "OPTIONS=--repeat"
- set "AUDIO_FILE=%WINDIR%\Media\tada.wav"
- :try_again
- cls
- echo ISP problems? This will alert you when your internet is back up. It will try to
- echo ping '%TARGET%' every %DELAY% seconds.
- echo.
- echo When a ping rebounds, this audio file will start:
- echo %AUDIO_FILE%
- ping -n 1 "%TARGET%" >nul
- if %ERRORLEVEL% EQU 0 (
- if exist "%VLC64%" (
- REM Use the 64-Bit version of VLC in repeat mode.
- start "" "%VLC64%" %OPTIONS% "%AUDIO_FILE%"
- ) else (
- if exist "%VLC32%" (
- REM Use the 32-Bit version of VLC in repeat mode.
- start "" "%VLC32%" %OPTIONS% "%AUDIO_FILE%"
- ) else (
- REM Resort to the default audio player.
- start "" "%AUDIO_FILE%"
- )
- )
- endlocal
- popd
- goto :EOF
- )
- timeout /t %DELAY% /nobreak
- goto :try_again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement