1.

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

Answer» <html><body><p>Hi!<br/><br/>I'm very new to batch files.  This is the <a href="https://interviewquestions.tuteehub.com/tag/first-461760" style="font-weight:bold;" target="_blank" title="Click to know more about FIRST">FIRST</a> time I have to write one.<br/><br/>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.  <br/><br/>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 =&amp;<a href="https://interviewquestions.tuteehub.com/tag/lt-537906" style="font-weight:bold;" target="_blank" title="Click to know more about LT">LT</a>; 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?<br/><br/>Thank you so much. <br/><br/><br/>BTW this batch file will be run on a Win Server 2003 box.Go to the command prompt and type in:<br/>echo %date%<br/>and tell us EXACTLY what it says. Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month<br/> Quote from: gregflowers on February 25, 2010, 01:32:39 PM</p><blockquote>Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month<br/><br/></blockquote> 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<blockquote>The OP did mention that he was using Windows Task Manager to run his batch . . .<br/></blockquote> I have problems reading lol. Quote from: reefshark on February 25, 2010, 10:52:18 AM<blockquote>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.  <br/></blockquote> <br/><br/>Use the /next option below.<br/><br/><br/>C:\&gt;at /?<br/>The AT command schedules commands and programs to run on a computer at<br/>a specified time and date. The Schedule service must be running to use<br/>the AT command.<br/><br/>AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]<br/>AT [\\computername] time [/INTERACTIVE]<br/>    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"<br/><br/>\\computername     Specifies a remote computer. Commands are scheduled on the<br/>                   local computer if this parameter is omitted.<br/>id                 Is an identification number assigned to a scheduled<br/>                   command.<br/>/delete            Cancels a scheduled command. If id is omitted, all the<br/>                   scheduled commands on the computer are canceled.<br/>/yes               Used with cancel all jobs command when no further<br/>                   confirmation is desired.<br/>time               Specifies the time when command is to run.<br/>/interactive       <a href="https://interviewquestions.tuteehub.com/tag/allows-857958" style="font-weight:bold;" target="_blank" title="Click to know more about ALLOWS">ALLOWS</a> the job to interact with the desktop of the user<br/>                   who is logged on at the time the job runs.<br/>/every:date[,...]  Runs the command on each specified day(s) of the week or<br/>                   month. If date is omitted, the current day of the month<br/>                   is assumed.<br/>/next:date[,...]   Runs the specified command on the next occurrence of the<br/>                   day (for example, next <a href="https://interviewquestions.tuteehub.com/tag/thursday-344074" style="font-weight:bold;" target="_blank" title="Click to know more about THURSDAY">THURSDAY</a>).  If date is omitted, the<br/>                   current day of the month is assumed.<br/>"command"          Is the Windows NT command, or batch program to be run.<br/><br/><br/>C:\&gt; Quote from: gregflowers on February 25, 2010, 01:32:39 PM<blockquote>Scheduled Tasks manager provides an option to "Run on the 'first' 'Sunday' of the Month<br/><br/></blockquote> <br/>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!<br/><br/>Thank you to <a href="https://interviewquestions.tuteehub.com/tag/everyone-25922" style="font-weight:bold;" target="_blank" title="Click to know more about EVERYONE">EVERYONE</a> for replying!</body></html>


Discussion

No Comment Found