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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i run a "silent" program that waits for a certain time??

Status
Not open for further replies.

Paladyr

Programmer
Apr 22, 2001
508
0
0
US
I want to alter my database backing up program to wait to run until around midnight and I don't know how to do it. Can someone link me to some usefull information or give me some direction on how to go about doing this?? Thanks!
 
Sounds like you need to write an out-of-process component, in the form of an ActiveX exe, which will fire an asynchonous event to notify the program of the time change. You can do this in-process as well, but I'm sure your program has enough things to worry about! Anyway, look in the MSDN documentation on component programming and read up on the Coffee Watch example. This will take care of you, however if there are simpler ways to do this... by all means, take suggestions from other posters. I know this is the way I'd personally go about it! Thanks!
LeGo PiEcE

"The Computer Spock! Destroy it!" - Captain James T. Kirk
 
You don't need that much precision, so try the
caveman approach

Do until canceled
figure_out_next_time_to_wake_up
Do until time_to_wake_up
Sleep(30000) 'sleep 30 seconds
time_to_wake_up =( _
Now() = time-of-next-event)
loop

....do what you gotta do
Loop
 
... or you can use Windows Scheduled Activities to start your application and perform your update on Form_Activate and close it nicely when done.

-Robert-
 
The easiest way to do this is just to stick all of your code into "Sub Main()" in a module, compile your EXE, and schedule it, like someone mentioned above. I do this quite frequently for all of my little utilities.. but i normally use VBScript for my "nightly tasks", just because i can make a change to it in the blink of an eye, and from any computer i might be at.

Just beware.. when you use the windows scheduling service, on NT4, Win2K, or whatever, you need to set the properties of your scheduled job to include the necessary network account/login - so that the job runs with the correct permissions for you to access network drives. And speaking of network drives, your network drives might not exist under this condition, and you may have to refer to the complete UNC (\\servername\share\path), or just remap your drive at the time of job execution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top