Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2004, 11:16 PM
Authorized User
 
Join Date: Apr 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default In program Scheduled Task

I have a program running in the background of my pc.
I'm looking for a way so that I can execute one of my functions at a specific time of the day, is it possible to 'hook' into the windows time events or something ? I don't want to have to add an entry into the scheduler.



 
Old August 29th, 2004, 11:05 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

When I had a similar situation, I did it in this way.

The client was having a dedicated server.

I requested them to open a page in a browser always in any machine (if possible on server itself).

That page used meta refresh which will make it reload every one hour.

I checked in that page whether the task is done for current hour. If no, I will do it and record the time in a log file.

This is working without any problem for the past 2 years.
 
Old August 31st, 2004, 12:28 PM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the program runs already you don't need the scheduler or anything. Just check in the program from time to time whether it's time to run that task. Just make sure you
  1. do not run the task twice jus because it finished quickly and it stil seems to be the right time to run it
  2. do not skip the task just because the application was busy at the scheduled time.

Which means you'll need to remember the last datetime it was run and you'll check whether the current time is after the scheduled time and the time of the last execution before the scheduled time. Or something like this.

It's hard to be more specific without knowing more about the design of your program.

 
Old August 31st, 2004, 12:35 PM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by madhukp
 When I had a similar situation, I did it in this way.

The client was having a dedicated server.

I requested them to open a page in a browser always in any machine (if possible on server itself).

That page used meta refresh which will make it reload every one hour.

I checked in that page whether the task is done for current hour. If no, I will do it and record the time in a log file.

This is working without any problem for the past 2 years.
Oh my gosh.
If all you have is a hammer all problems start to look like nails, rigth?

This is very awkward solution and let me tell you something, if a consultant (or whatever you want to call the person) suggested something like this I would know I need to find another.

Even if you do stick to VBScript you can do much better.
Do rewrite the "program" so that it works from within Windows Scripting Host (wscript/cscript, see microsoft.com) and have it scheduled at the rigth time each day.

 
Old August 31st, 2004, 11:32 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello Jenda,

I agree the above method is not the best one. The best method is to do it in VBS and put it in scheduler. But the poster ginoitalo had said he cannot put anything in the scheduler. Haven't you noticed it ?

The answer should be suitable to the particular situation in which the person is. If you know any other method other than VBS and meta refresh, then post it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add task in Scheduled Task programatically amitjoshipune C# 2 July 31st, 2008 05:42 AM
Scheduled task langer123 Classic ASP Basics 0 March 16th, 2005 11:14 AM
[c#]scheduled task maddonuts General .NET 1 July 7th, 2004 11:53 AM
Creating a Scheduled Task jayabhatia .NET Web Services 3 February 25th, 2004 08:37 AM
Scheduled Task Ben Access VBA 1 February 24th, 2004 02:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.