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

Time questions 2

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I want to copy a file at a certain time each day. (3:00 PM)

How can I do this in VB?
I am familiar with NOW but I only need the time not the date.

Thanks

fergmj
 
The easy way:
Write a VB program to copy the file, then under NT/2000 use the AT command to call it each day.

The hard way:
Write a VB program that runs all the time, watching the clock.
[tt]
Dim sTimeOnly as String

Do
[tab]DoEvents
[tab]sTimeOnly = Format$(now, "hh:nn:ss") ' 24 hour time
[tab]If sTimeonly = "14:30:00" Then
[tab][tab]'Time to run
[tab]End If
Loop
[/tt]

Note that this code is very inefficient, as it is continually checking the time (i.e. it's hammering your system). A better solution would be to check the time only every 10 minutes or so. Use a timer control to delay between checking.

Chip H.
 
Thanks. I appreciate the help.

fergmj
 
ChipH -

Explain the AT command in NT/2000. Sounds like a better way to go. This app needs to only run twice a day so why have it running all the time.

Are you talking about the Task Scheduler in NT?

fergmj
 
Yes, the task scheduler. I think there's a new GUI around it in 2000, but I learned under NT 3.51, so I still use it via command-line.

Click on Start | Help, then search for "at command, using the at command" to get the online help for it. Note that you can also schedule jobs to run on remote computers.

You can be clever and surround several commands in a .cmd file, then schedule the command (batch) file to run.

Chip H.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top