Question:
Is there any way to make a batch file not do anything until a certain date?
vidkid1990
2009-02-18 19:09:20 UTC
I'm new at making batch files, and I have the following code, but don't even know what's wrong with it, if anything at all. I copied this code from a tutorial, and it's supposed to put the current date into a variable called "date."

FOR /F “TOKENS=1* DELIMS= ” %%A IN (’DATE/T’) DO SET CDATE=%%B
FOR /F “TOKENS=1,2 eol=/ DELIMS=/ ” %%A IN (’DATE/T’) DO SET mm=%%B
FOR /F “TOKENS=1,2 DELIMS=/ eol=/” %%A IN (’echo %CDATE%’) DO SET dd=%%B
FOR /F “TOKENS=2,3 DELIMS=/ ” %%A IN (’echo %CDATE%’) DO SET yyyy=%%B
SET date=%mm%%dd%%yyyy%

My question is really two-part:
1.) Is this code functional?
2.) How do I format an if-then-else statement to do something IF the current date is greater-than a preset date?
Three answers:
Mukesh
2009-02-18 19:19:02 UTC
no dude.. the only thing u can do is set the batch file under scheduled task.. which will autorun on a specified date.



and FOR command is not for time schedule.. it is used for setting up independent tasks for a set of files in folder..



This command is a bit complicated but just takes out the time of setting up the commands because u dont need to give the path after each command is entered.
2016-10-18 16:26:07 UTC
you be attentive to its a sin now, do no longer you? as in case you probably did no longer before...sigh. So, repent. The organic opposition could arrise - yet what if somebody polluted then died before this became into introduced? the respond is that pollution has continuously been a sin whether it wasnt formally declared. you are able to bypass returned to genesis for that the place God commanded us to be stable stewards to the Earth.
crazyap7
2009-02-20 14:59:06 UTC
1.) I don't know, I don't mess with for statements, sorry :(

2.) This is a multipart answer:

a. Add to the top of your batch file:

if %DATE%=='datethatyouwant' goto :TAGFORRESTOFPROGRAM

if NOT %DATE%=='datethatyouwant' exit



b. Now add this program to your windows startup folder.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...