1.

Solve : How do I create batch file to run on 1st Sunday of each month??

Answer»

Hi!

I'm very new to batch files.  This is the FIRST time I have to write one.

I need to write a batch file that will do 'something' but only on the 1st Sunday of each month and at a specified time, say 3 AM. 

I had the idea of using the Scheduled Tasks manager in Windows to run my batch file each Sunday and at a specified time, then define the 1st Sunday in the batch file (something like, "if SUN and DD =< 7".  If it is not the 1st Sunday, then just do nothing and exit the batch file.  The only thing is I don't know the syntax to define the 1st Sunday and specific time.  Can someone help me out?

Thank you so much.


BTW this batch file will be run on a Win Server 2003 box.Go to the command prompt and type in:
echo %date%
and tell us EXACTLY what it says. Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month
Quote from: gregflowers on February 25, 2010, 01:32:39 PM

Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month

I was thinking of an all-batch solution, but then it wouldn't run automatically, it just wouldn't do anything if it wasn't the first Sunday. The OP did mention that he was using Windows Task Manager to run his batch . . . Quote from: gregflowers on February 25, 2010, 01:38:09 PM
The OP did mention that he was using Windows Task Manager to run his batch . . .
I have problems reading lol. Quote from: reefshark on February 25, 2010, 10:52:18 AM
I need to write a batch file that will do 'something' but only on the 1st Sunday of each month and at a specified time, say 3 AM. 


Use the /next option below.


C:\>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       ALLOWS the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next THURSDAY).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.


C:\> Quote from: gregflowers on February 25, 2010, 01:32:39 PM
Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month


Duh, I feel real stupid now.  When I was originally setting up the task, I didn't select the correct options to see that I would be able to select the 'first' Sunday of the month.  But since you mentioned it, I went back and saw the option.  Thanks for your help!

Thank you to EVERYONE for replying!


Discussion

No Comment Found