Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB6 - Using NetScheduleJobAdd to schedule a task to run every X mi

2 views
Skip to first unread message

Snuffy2

unread,
Apr 13, 2005, 9:59:02 PM4/13/05
to
After browsing around I've found a way to programatically at a scheduled task
into WinXP. The only problem is, the shortest interval I can get it to run
is once a day. If I manually create a task I can get it to run every X min.

I need to be able to get a scheduled task created programatically in VB6 to
run every X min, it also needs to run as logged in user so it wont require a
password.

If there's a different way besides NetScheduleJobAdd in VB6 I'd be up for
that as well.

Here is where I found the code for the creation of the scheduled task:
http://www.veign.com/vrc_codeview.asp?type=app&id=87

Sam Hobbs

unread,
Apr 13, 2005, 10:28:15 PM4/13/05
to
"Snuffy2" <Snu...@discussions.microsoft.com> wrote in message
news:C12DF7EA-286E-459F...@microsoft.com...

>
> I need to be able to get a scheduled task created programatically in VB6
> to
> run every X min, it also needs to run as logged in user so it wont require
> a
> password.

If it truly needs to run every minute, it would be easy to write a program
that executes the task every minute.


Snuffy2

unread,
Apr 13, 2005, 10:44:02 PM4/13/05
to
"Sam Hobbs" wrote:

> If it truly needs to run every minute, it would be easy to write a program
> that executes the task every minute.

Nope. i need to actually create a scheduled task. This is code I'm trying to
use for a few different programs I'm working on. The task might run every
hour, every 5 min, or every day (can already be done). I'm basically trying
to get this so I can use it in all my future apps that might require a
scheduled task.

Sam Hobbs

unread,
Apr 14, 2005, 3:36:27 PM4/14/05
to
"Snuffy2" <gmail.com.at.snuffy2.backwards> wrote in message
news:88B3C8D3-11A8-40BF...@microsoft.com...

I know that there have been many previous questions and answers in this
newsgroup that are relevant. Other than that, I don't know anything about it
myself.


Mark Yudkin

unread,
Apr 17, 2005, 4:15:10 AM4/17/05
to
Go to http://www.mvps.org/emorcillo/en/code/vb6/index.shtml and download the
code from "Using the Task Scheduler".

"Snuffy2" <Snu...@discussions.microsoft.com> wrote in message
news:C12DF7EA-286E-459F...@microsoft.com...

Snuffy2

unread,
Apr 17, 2005, 2:19:57 PM4/17/05
to
I have looked through that code extensively, but I am unable to find a way
to use that code to set the interval minutes. If you have, I'd love to know
how.

Thanx

"Mark Yudkin" <myudkinATcom...@boing.org> wrote in message
news:%2368SvVy...@TK2MSFTNGP10.phx.gbl...

Mark Yudkin

unread,
Apr 18, 2005, 9:38:01 AM4/18/05
to
Take a GOOD look at trigger.cls and the Platform SDK documentation on the
task scheduler.

You can't set minutes per se, but you can set multiple daily schedules, so
provided X is a divisor of 1440, you can set up 1440/X daily schedules. This
is how the XP task scheduler is documented, and it's what Eduardo did in his
code.

"Snuffy2" <snu...@yahoo.com> wrote in message
news:uxGMQo3Q...@TK2MSFTNGP15.phx.gbl...

Snuffy2

unread,
Apr 20, 2005, 1:57:13 PM4/20/05
to
So you're saying if I wanted to have this run every 5 min in the task
scheduler i'd create (1440/5) 288 Separate schedules? or every hour
(1440/60) 24 schedules?

That doesn't seem like the best way to do it. Unless I'm mising something.

"Mark Yudkin" <myudkinATcom...@boing.org> wrote in message

news:OugSzuBR...@TK2MSFTNGP09.phx.gbl...

Mark Yudkin

unread,
Apr 22, 2005, 3:11:59 AM4/22/05
to
As I said last time:

> Take a GOOD look at trigger.cls and the Platform SDK documentation on the
> task scheduler.

I very strongly recommend you do this, as it answers your questions and
saves us both a lot of time.

---

You can use the MinutesDuration and MinutesInterval options to schedule down
to 1 minute. This is not quite the same thing as scheduling every 5 minutes,
but might do what you actually want (and is how MS handle notifications in
Sharepoint). This is available in Eduardo's Trigger class (Durations and
Interval properties, as per Eduardo's code in the trigger.cls, that you
appear not to want to look at).

From the Platform SDK, that you also appear not to want to read:

MinutesDuration
Number of minutes after the task starts that the trigger will remain active.
The number of minutes specified here must greater than or equal to the
MinutesInterval setting.
For example, if you start a task at 8:00 A.M. and want to repeatedly start
the task until 5:00 P.M., there would be 540 minutes in the duration.

MinutesInterval
Number of minutes between consecutive task executions. This number is
counted from the start of the previous task. The number of minutes specified
here must be less than or equal to the MinutesDuration setting.
For example, to run a task every hour from 8:00 A.M. to 5:00 P.M., set this
field to 60.

"Snuffy2" <snu...@yahoo.com> wrote in message

news:%236RviJd...@TK2MSFTNGP10.phx.gbl...

Snuffy2

unread,
Apr 28, 2005, 4:21:34 PM4/28/05
to
Thank you for your help, figured it out.


"Mark Yudkin" <myudkinATcom...@boing.org> wrote in message

news:%2333Fxpw...@TK2MSFTNGP10.phx.gbl...

0 new messages