creating schtasks to run for a date range every month

  • Thread starter Thread starter R. Berger
  • Start date Start date
R

R. Berger

Guest
I am attempting to use schtasks to create some scheduled tasks to run
on a monthly basis but am having trouble figuring out the right syntax
to get the desired behavior. Basically, I want to run a batch file
every day (during the desired date range) starting at a specific
time. Some examples:

I want a batch file to run every 23rd-30th of each month,
starting at 1:00am.
I want a batch file to run every 23rd-30th of each month,
starting at 10:00am.

I want a batch file to run every 15th-21st of each month,
starting at 1:00am.
I want a batch file to run every 15th-21st of each month,
starting at 10:00am.

The day-of-month range would be the same every month. There doesn't
appear to be a way to specify more than one day, or a day range with
the /d parameter. Is the only way to accomplish this to create a
separate scheduled task for each day of my desired range? Thanks in
advance for any help.

Roy Berger
 
Re: creating schtasks to run for a date range every month


"R. Berger" <roybrew@att.net> wrote in message
news:e1053516-4d92-4f2d-9e58-3d95bc27c45f@y21g2000hsf.googlegroups.com...
>I am attempting to use schtasks to create some scheduled tasks to run
> on a monthly basis but am having trouble figuring out the right syntax
> to get the desired behavior. Basically, I want to run a batch file
> every day (during the desired date range) starting at a specific
> time. Some examples:
>
> I want a batch file to run every 23rd-30th of each month,
> starting at 1:00am.
> I want a batch file to run every 23rd-30th of each month,
> starting at 10:00am.
>
> I want a batch file to run every 15th-21st of each month,
> starting at 1:00am.
> I want a batch file to run every 15th-21st of each month,
> starting at 10:00am.
>
> The day-of-month range would be the same every month. There doesn't
> appear to be a way to specify more than one day, or a day range with
> the /d parameter. Is the only way to accomplish this to create a
> separate scheduled task for each day of my desired range? Thanks in
> advance for any help.
>
> Roy Berger


You could use the Task Scheduler GUI to create tasks with multiple
schedules. Alternatively you could schedule the task to run at 1am
every day of the month and get it to invoke a batch file with some
inbuilt intelligence:
@echo off
set DOM=%date:~7,2%
if %DOM% LSS 23 goto :eof
if %DOM% GTR 30 goto :eof
{your command goes here}
 
Re: creating schtasks to run for a date range every month

On Jul 7, 12:29 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "R. Berger" <royb...@att.net> wrote in message
>
> news:e1053516-4d92-4f2d-9e58-3d95bc27c45f@y21g2000hsf.googlegroups.com...
>
>
>
>
>
> >I am attempting to use schtasks to create some scheduled tasks to run
> > on a monthly basis but am having trouble figuring out the right syntax
> > to get the desired behavior.  Basically, I want to run a batch file
> > every day (during the desired date range) starting at a specific
> > time.  Some examples:

>
> >         I want a batch file to run every 23rd-30th of each month,
> > starting at 1:00am.
> >         I want a batch file to run every 23rd-30th of each month,
> > starting at 10:00am.

>
> >         I want a batch file to run every 15th-21st of each month,
> > starting at 1:00am.
> >         I want a batch file to run every 15th-21st of each month,
> > starting at 10:00am.

>
> > The day-of-month range would be the same every month.  There doesn't
> > appear to be a way to specify more than one day, or a day range with
> > the /d parameter.  Is the only way to accomplish this to create a
> > separate scheduled task for each day of my desired range?  Thanks in
> > advance for any help.

>
> > Roy Berger

>
> You could use the Task Scheduler GUI to create tasks with multiple
> schedules. Alternatively you could schedule the task to run at 1am
> every day of the month and get it to invoke a batch file with some
> inbuilt intelligence:
> @echo off
> set DOM=%date:~7,2%
> if %DOM% LSS 23 goto :eof
> if %DOM% GTR 30 goto :eof
> {your command goes here}- Hide quoted text -
>
> - Show quoted text -


I'm trying to dumb this down for a non-admin user (regular user). The
GUI, while I can use it, is fairly intimidating for the casual user.
I can probably do something like you suggest. Was hoping for
something "built-in" to schtasks. I guess not. I have some
intelligence built into the software that my batch file runs, which
allows the process to retry N times per day, M minutes apart. I was
hoping to not have to write a scheduler. Again, maybe I can do
something like you suggest in a batch file hack.
 
Back
Top