Buat project baru
buat seperti ini di form
download file di link ini dan ekstrack
https://mega.nz/#!awA1SSYZ!ZeGfg9kPQmxg_U4dHTN4yXHdpX-5ht1qaOi9FAtd41Y
add reference Microsoft.Win32.TaskScheduler dari folder yang di download
Simpan file Sleep.bat dan Wakeup.bat di drive D
Masukan skrip di bawah ini
Imports Microsoft.Win32.TaskScheduler
Public Class TaskSchedule
Private Sub setSleep_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles setSleep.Click
Using ts As New TaskService()
' Create a new task definition and assign properties
Dim td As TaskDefinition = ts.NewTask
td.RegistrationInfo.Description = "For Sleep PC"
Dim dt As New DailyTrigger
dt.StartBoundary = Format(DateTimePicker1.Value, "dd/MM/yyyy HH:mm:ss")
dt.DaysInterval = 1
dt.Enabled = True
td.Triggers.Add(dt)
' Add an action (shorthand) that runs Notepad
td.Actions.Add(New ExecAction("D:\Sleep.bat"))
td.Settings.StopIfGoingOnBatteries = False
td.Settings.StartWhenAvailable = False
' Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition("Auto Sleep PC", td)
End Using
End Sub
Private Sub setWakeup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles setWakeup.Click
Using ts As New TaskService()
' Create a new task definition and assign properties
Dim td As TaskDefinition = ts.NewTask
td.RegistrationInfo.Description = "For Wakeup PC"
Dim dt As New DailyTrigger
dt.StartBoundary = Format(DateTimePicker2.Value, "dd/MM/yyyy HH:mm:ss")
dt.DaysInterval = 1
dt.Enabled = True
td.Triggers.Add(dt)
td.Actions.Add(New ExecAction("D:\wake.bat"))
td.Settings.StopIfGoingOnBatteries = False
td.Settings.WakeToRun = True
ts.RootFolder.RegisterTaskDefinition("Wake From Sleep", td)
End Using
End Sub
End Class
Running aplikasi nya, atur waktunya dan klik set sleep dan set wakeup
Buka task schedule dari windows
lihat hasilnya di task schedule
dan tunggu waktunya sampai windows sleep dan wakeup kembali
Good luck
Tidak ada komentar:
Posting Komentar