开发者

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!


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


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

type this in anything.bat:

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

:start  
start "your program"   
goto end   
:end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜