Shutdown Service VB.NET - CLOSED
I'm trying to make a service that will shutdown the computer at a certain time in the day so once everyone has gone home the machines aren't left on over night. I am using Visual Studio 2010 Ultimate to create a service that runs even if the machines logged off. I have been able to create the service and it runs, but when it gets to the time I set up the top it does nothing. Any help with this would be great
Public Class Service1
'Setting time to shutdown macine
Private AlarmTime As Date = "17:00:00"
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.
'Enabling Timer - tmrUp
tmrUp.Enabled = True
AddHandler tmrUp.Tick, AddressOf tmrUp_Tick
tmrUp.Interval = 1000
Catch ex As Exception
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
tmrUp.Enabled = False
Private Sub tmrUp_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrUp.Tick
If AlarmTime.Hour = Now.Hour And AlarmTime.Minute = Now.Minute And AlarmTime.Second = Now.Second Then
Process.Start("shutdown", "-r -f -t 0")