Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start Command at Certain Time

Status
Not open for further replies.

TGrahmann

Programmer
Feb 19, 2015
43
US
Greetings, I am posed with an issue that I have no idea how to resolve. I want to use a timer (that is also bound to a clock) to run a command at a user defined time, but with no specific date. How would I go about this?
 
One option would be to use the Windows Scheduler, which would do the whole thing for you without any programming on your part.

Alternatively, write a small program to trigger the command. That program would run the whole time on the user's system. It doesn't necessarily need a user interface; you can make it invisible (by setting SCREEN = OFF in its Config.fpw file).

The program would initiate a timer. Set the timer interval to, say, 5 minutes. In the Timer event, check to see if the current time is within five minutes of your scheduled start time. If it is, disable the timer, run your process, then re-enable the timer. The date is not relevant.

The smaller the timer interval, the closer you will get to running the command at exactly the right time, but at the expense of a slight additional overhead on the system.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The scheduler is really the place to go, besides choosing a time table eg only weekdays, only weekends or whatever other schedule, you specify which system account or domain account starts a process or any executable file. Use this system tool, don't reinvent the wheel. I don't see a benefit of writing a timer routine, may it be as simple to do, using the scheduler gives your customer more control about what's scheduled, results can even be seen in the windows event log. You have a lot of benefits with just using the tool given and it's set up within minutes.

[URL unfurl="true"]http://www.7tutorials.com/how-create-task-basic-task-wizard[/url]

Bye, Olaf.
 
The main reason I suggested an alternative to using the schedule was because I don't know if Mr Grahmann has access to the users' systems, or whether he can rely on them to set up a scheduled task. And I don't know how easy it is to set up a scheduled task programmatically.

But if that's not a problem, of course the Windows Scheduler is the way to go. That's precisely what it is there for.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
MikeLewis said:
...
The date is not relevant.
Well, yes and no. What I do when running an app daily is save the last run date. I then check the time every few minutes with a timer to see if the time is >= run time. If it is, I then compare the current date with the last run date to make sure it is the next day.
+ or - 5 minutes could make the process run more than once if it runs fast.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top