How do I make a batch file that can run certain commands based on the date?

How do I make a batch file that can run certain commands based on the date?



I was wondering how to make a batch file that runs a certain command/commands based on the date. I have a script that is based on the day of the week:


IF %DATE:~0,3%==Mon CALL (File/program/directory)

IF %DATE:~0,3%==Tue CALL (File/program/directory)

IF %DATE:~0,3%==Wed CALL (File/program/directory)

IF %DATE:~0,3%==Thu CALL (File/program/directory)

IF %DATE:~0,3%==Fri CALL (File/program/directory)

IF %DATE:~0,3%==Sat CALL (File/program/directory)

IF %DATE:~0,3%==Sun CALL (File/program/directory)



But I need one more specific, like it runs a program on someone's birthday.
Thanks for your help!






Just use the task scheduler/AT to run the file?

– Alex K.
Apr 24 '11 at 13:23






I am not just trying to get the job done, I'm expanding my knowledge of batch files.

– Ian
Apr 25 '11 at 23:56




2 Answers
2



If you do it the same way like your current solution, it should be simple.

But it depends on your date/time format.


if "%DATE:~9,5%"=="11/04" call birthdayOfPeter.bat






Thank you for your help. This is very useful information. Do you know where I can get a list of date formats?

– Ian
Apr 26 '11 at 0:08



There is another method to do it.



this code will start your program on 11/02/2014 (edit when ever you want to start)
copy anything.bat to startup


11/02/2014


anything.bat



type this in anything.bat:


anything.bat


@echo off
:finddate
if %date% GEQ 11/02/2014 goto start
goto finddate

:start
start "your program"
goto end
:end



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)