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

How to schedule a VBScript to run every five minutes

1,560 views
Skip to first unread message

gimme_this...@yahoo.com

unread,
Oct 7, 2008, 5:03:07 PM10/7/08
to
I'm using XP SP2.

I tried setting up a task using Task Scheduler to run:

Every 5 minutes from 6:26 PM for 1 hours(s) every day, starting
10/6/2008 and ending 9/7/2009.

But this ran once and that was it.

Any ideas?

Pegasus (MVP)

unread,
Oct 7, 2008, 6:01:53 PM10/7/08
to

<gimme_this...@yahoo.com> wrote in message
news:22a9f77a-7be2-4674...@a3g2000prm.googlegroups.com...

What duration did you set?


James Whitlow

unread,
Oct 7, 2008, 9:16:08 PM10/7/08
to
<gimme_this...@yahoo.com> wrote in message
news:22a9f77a-7be2-4674...@a3g2000prm.googlegroups.com...

You can use the command line task scheduler (watch for wrapping):

schtasks.exe /Create /TN "My Task" /TR "C:\Test.vbs" /RU System /SC Minute
/MO 5

gimme_this...@yahoo.com

unread,
Oct 7, 2008, 9:59:53 PM10/7/08
to
Wow James.

Quite a solution.

I need to run it on three tasks:

For task one:

0,5,10,15,20,25,30,35,40,45,50,55

For task two:

1,6,11,16,21,26,31,36,41,46,51,56

And task three:

2,8,12,17,22,27,32,37,42,47,52,57

So how do I set up the start time to get this to happen?

Thanks!

gimme_this...@yahoo.com

unread,
Oct 7, 2008, 10:01:01 PM10/7/08
to
On Oct 7, 3:01 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <gimme_this_gimme_t...@yahoo.com> wrote in message

gimme_this...@yahoo.com

unread,
Oct 7, 2008, 10:01:38 PM10/7/08
to

> What duration did you set?

One hour.

What does duration refer to? What should it be?

Thanks.

James Whitlow

unread,
Oct 7, 2008, 10:23:07 PM10/7/08
to
<gimme_this...@yahoo.com> wrote in message
news:f733cf48-1519-45e4...@k36g2000pri.googlegroups.com...

> Wow James.
>
> Quite a solution.
>
> I need to run it on three tasks:
>
> For task one:
>
> 0,5,10,15,20,25,30,35,40,45,50,55
>
> For task two:
>
> 1,6,11,16,21,26,31,36,41,46,51,56
>
> And task three:
>
> 2,8,12,17,22,27,32,37,42,47,52,57
>
> So how do I set up the start time to get this to happen?

You can use the '/ST' switch to specify a start time. Modifying the
original example to have it start at 4 PM:

schtasks.exe /Create /TN "My Task" /TR "C:\Test.vbs" /RU System /SC Minute

/MO 5 /ST 16:00:00

You can type 'schtasks.exe /Create /?' at the command prompt to get the
syntax and a listing of the switches.

For your examples above, just start task one at the beginning of the
hour (/ST 16:00:00), task two at one minute past (/ST 16:01:00) & task three
for two minutes after (/ST 16:02:00). Modify for your preferred starting
hour...


Al Dunbar

unread,
Oct 7, 2008, 10:21:57 PM10/7/08
to
I'm confused as to what you want to do, here...

<gimme_this...@yahoo.com> wrote in message
news:f733cf48-1519-45e4...@k36g2000pri.googlegroups.com...


> Wow James.
>
> Quite a solution.
>
> I need to run it on three tasks:
>
> For task one:
>
> 0,5,10,15,20,25,30,35,40,45,50,55

what are these numbers? offsets in minutes from 6:26? Is this task supposed
to start at 6:26, 6:31, 6:36, and etc? how long will each instance run
before it stops running? If more than 5 minutes, each of those will need to
be scheduled separately.

/Al

Al Dunbar

unread,
Oct 7, 2008, 10:21:52 PM10/7/08
to

<gimme_this...@yahoo.com> wrote in message
news:22a9f77a-7be2-4674...@a3g2000prm.googlegroups.com...

If it starts on october 6th it is already finished, as september 7th is long
past.

/Al


Dave Patrick

unread,
Oct 7, 2008, 11:41:52 PM10/7/08
to
Set it to 24 hours if you want it to run continuously. If you set it for
every five minutes for 12 hours beginning at 1:00 AM then it would run every
five minutes from 1:00 AM to 1:00 PM

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

Todd Vargo

unread,
Oct 8, 2008, 12:13:01 AM10/8/08
to
gimme_this...@yahoo.com wrote:
> Wow James.
>
> Quite a solution.
>
> I need to run it on three tasks:
>
> For task one:
>
> 0,5,10,15,20,25,30,35,40,45,50,55
>
> For task two:
>
> 1,6,11,16,21,26,31,36,41,46,51,56
>
> And task three:
>
> 2,8,12,17,22,27,32,37,42,47,52,57
>
> So how do I set up the start time to get this to happen?

I'm not sure if this is what you are after but give it a try and let us
know.

Set WshShell = WScript.CreateObject("WScript.Shell")
Dim begin, mystop, endtime, last, current

begin = #6:26 PM#
mystop = #7:26 PM#
endtime = #9/7/09 7:26 PM#

last = Minute(Now) - 1 'prime the pump
Do
Current = Now
If current > endtime Then
Wscript.Echo current & " is after " & endtime
Exit Do
ElseIf TimeValue(current) > Begin And _
TimeValue(current) < mystop Then
If last = Minute(current) Then
Wscript.Sleep 5000
Else
Select Case Minute(current)
Case 0,5,10,15,20,25,30,35,40,45,50,55
Wscript.Echo "Task1" '<=== .run Task1 here
Case 1,6,11,16,21,26,31,36,41,46,51,56
Wscript.Echo " Task2" '<=== .run Task2 here
Case 2,8,12,17,22,27,32,37,42,47,52,57
Wscript.Echo " Task3" '<=== .run Task3 here
End Select
last = Minute(current)
End If
Else
Wscript.Sleep 60000 'wait a minute.
End If
Loop

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Martín

unread,
Oct 8, 2008, 3:38:09 PM10/8/08
to
Look at the command: AT

<gimme_this...@yahoo.com> escribió en el mensaje de
noticias:22a9f77a-7be2-4674...@a3g2000prm.googlegroups.com...

gimme_this...@yahoo.com

unread,
Oct 8, 2008, 5:12:54 PM10/8/08
to
Thanks Dave,

Your suggestions worked for me.

gimme_this...@yahoo.com

unread,
Oct 8, 2008, 5:17:14 PM10/8/08
to
Thank you Todd,

Yes - it wasn't what I wanted.

But I think it's cool how it works. With your script I don't have to
schedule the tasks.

Also I've never saw Minute and TimeValue before.


On Oct 7, 9:13 pm, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:

> (Post questions to group only. Remove "z" to email personal messages)- Hide quoted text -
>
> - Show quoted text -

Dave Patrick

unread,
Oct 8, 2008, 11:19:24 PM10/8/08
to
You're welcome.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

Todd Vargo

unread,
Oct 8, 2008, 11:17:11 PM10/8/08
to
gimme_this...@yahoo.com wrote:
> Thank you Todd,
>
> Yes - it wasn't what I wanted.
>
> But I think it's cool how it works. With your script I don't have to
> schedule the tasks.
>
> Also I've never saw Minute and TimeValue before.

Download script56.chm from the Microsoft site.

0 new messages