Thursday, September 8, 2011

15 min Alarm part3

This is the 'relative time' based reminder. it will play a song every 5 mins , one can always change the time . The time specified is in seconds and cannot exceed 999 secs.

REM File name: Reminder.bat
REM Description: this is a Batch file that plays a song every 5 mins.
REM one can change the time by changing the number of secs which is here as '300' in the CHOICE statement.
REM The song can be specified in place of "D:\dwnlds\AIRTEL.wav"
:again
echo off
CHOICE /n /C 12 /d 1 /t 300
if errorlevel == 1 goto sing
if errorlevel == 2 goto sing

:sing
start "C:\Program Files\Windows Media Player\wmplayer.exe" "D:\dwnlds\AIRTEL.wav"

15 min Alarm part2

So , here i am with the code. Rather i have two. I have one which is based in 'absolute times' using the system clock and the other is based on 'relative time'.

This is the code for the 'absolute time' based reminder. Reminds at 10,20,30,40,50 and 00 minutes on the clock.

REM File name: Reminder.bat
REM Description: this is a Batch file that plays a song every 10 mins.
REM The song can be specified in place of "D:\dwnlds\AIRTEL.wav"
:again
@echo off
REM Takes the system time
set t=%time%
REM t2 = seconds
set t2=%t:~6,2%
REM t1 = minutes
set t1=%t:~3,2%
REM One can specify at what minutes do you want a reminder
if %t1%==00 goto alarm
if %t1%==10 goto alarm
if %t1%==20 goto alarm
if %t1%==30 goto alarm
if %t1%==40 goto alarm
if %t1%==50 goto alarm

REM provides a delay of 1 sec.
CHOICE /n /C 12 /d 1 /t 1
cls
if errorlevel == 1 goto again
if errorlevel == 2 goto again


:alarm
if %t2%==30 goto sing
cls
goto again


:sing
REM can provide the link to the desired media player like VLC,etc.
REM provide the link to the compatible audio file .
start "C:\Program Files\Windows Media Player\wmplayer.exe" "D:\dwnlds\AIRTEL.wav"

REM provides a delay of 1 minute.
CHOICE /n /C 12 /d 1 /t 60
cls
if errorlevel == 1 goto again
if errorlevel == 2 goto again
goto again