Hi
I need to run some code to copy some files from one place to another at a specific time.
The PC this is running on won't have a user logged in at the time, so I understand this requires a windows service.
I've created this and added a system timer - from what I've researched the regular timer won't work. Test code is below:
Code:Public Class Service1 Public launchtime As String = "8:55" Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work. Timer1.Start() End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. End Sub Private Sub Timer1_Elapsed(sender As Object, e As Timers.ElapsedEventArgs) Handles Timer1.Elapsed Dim mytime As DateTime = Nothing mytime = Convert.ToDateTime(launchtime) If mytime.Hour = Now.Hour And mytime.Minute = Now.Minute Then MsgBox("Hello it is: " & launchtime) End If End Sub End Class
I've got my startup object set to the name of the service - I assume this is all that's needed to fire the onstart event and begin the timer?
I've added ServiceProcessInstaller (account set to LocalService) and ServiceInstaller (startup set to Automatic)
I've installed as a service and I can see it in Windows services, set to Auto. I've also started it from here.
Nothing is happening at 8:55 though (I just hard coded this in and used a messagebox while I'm testing)
Could anyone suggest what I've overlooked?
Thanks!




Reply With Quote
