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!

Program to run automatically

Status
Not open for further replies.

PNorman

Programmer
Feb 7, 2005
30
0
0
US
Hi, I'm writing a VB 6 app. which will back-up files either manually or automatically. I'm not sure how to make it automatic(such as having it run as a scheduled task like Norton Anti-Virus). Any ideas how I implement this ability?

Thanks
 
Use Scehduled Tasks.

Start -> programs -> Accessories -> System Tools -> Scheduled Tasks

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I know that but how do I make the application start to perform a back-up automatically as a Scheduled Task without it performing a back-up when started manually?
 
Why would you start it manually if you didn't want it to perform a back up? Isn't that that application's purpose?

"Pin me. Perl me."

Regards,

Chris
 
Maybe you cound add a command line parameter.

In your app...

Code:
Private Sub Form_Load()

    If InStr(Command, "NOW") Then
        MsgBox Command
    End If
    
End Sub

Then, in the scheduler, add the word NOW at the end of the run command.

Of course, you'll want to change the code to NOT display a messagebox but instead immediately create a backup. If NOW is not found on the command line, then don't immediately create a backup, but show your app normally.

Hope this helps.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Another alternative that I've used is to start a "countdown timer" when the application starts, and have a STOP button on your form to stop the timer. Set it at 10-20 seconds so a user has time to stop the timer before it counts down to zero. If it does get to zero, unload or hide the form and do whatever it is you need to do (i.e. start a backup).


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I wrote a .NET service which every 24 hours, automatically copied a database and created a new backup sub folder and dumped the database in there.

I'm not sure how (or if) you can write windows services in VB6. It was a good solution as I just stopped the service when I didn't want it to run like you would any other windows service
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top