Time Event

ziggyster2002

New member
Joined
Oct 10, 2006
Messages
1
Programming Experience
Beginner
Hi all

i wont my program to to shut down windows at a certain time for exsample 3:00 am i have the shell command that shuts down windows just not sure how to set it so that it will shut down at that time. iam using vb 6

ive haunted round all day trying to find this code lol

thanks in advance
 
Windows XP has got Task Scheduler where you can appoint commands.

What's that vb6? You want to upgrade it to VB.Net? Only VB.Net at these forums, you know.
 
The following would be a good start structure for your goal. Checking every minute to see if its time yet.

VB.NET:
Option Explicit
Private Sub Form_Load()
    Me.Timer1.Interval = 60000
    Me.Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()

Dim myShutdownTime As Date
Dim myCurrentTime As Date

    myShutdownTime = CDate(#3:00:00 AM#)
    myCurrentTime = CDate(Hour(Now) & ":" & Minute(Now))
    
    If myCurrentTime >= myShutdownTime Then
        'Execute Shell Command.
    Else
        'Do Nothing. Continue Loop.
    End If

End Sub
 
Windows XP has got Task Scheduler where you can appoint commands.

What's that vb6? You want to upgrade it to VB.Net? Only VB.Net at these forums, you know.


lol, good point John. Time for some one to upgrade ;-) I gave the 6.0 answer without thinking =( *Goes to the corner*
 
Back
Top