Kamis, 22 Oktober 2015

DELETE FOLDER DAN ALL FILE TANPA PERMASALAHAN ACCESS DENIED

Dim path As String =  "D:\Coba" 'Coba adalah nama folder yang berisi file-file
Dim r = My.Computer.FileSystem.GetDirectoryInfo(path)
r.Attributes = FileAttributes.Normal
My.Computer.FileSystem.DeleteDirectory(path, FileIO.DeleteDirectoryOption.DeleteAllContents)

Kamis, 08 Oktober 2015

CARA MEMBUAT AUTOSLEEP DAN AUTO WAKEUP SETIAP HARI DI WINDOWS MENGGUNAKAN TASK SCHEDULER WINDOWS

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