Basit Khan

Basit Khan

  • NA
  • 336
  • 121.6k

TaskSheduler in .Net

Nov 17 2016 6:01 AM
Hi,
 
I download the dll file from http://taskscheduler.codeplex.com/.
 
i also add reference Imports Microsoft.Win32.TaskScheduler
 
Below code is working after one minute and then open notepad file.
 
What i want is Weekly basis Monday, tuesday and wed at around 11:00 AM this sheduler fire.
 
How to do this. 
 
Private Shared Sub Main()
Using ts As New TaskService()
' Create a new task definition and assign properties
Dim td As TaskDefinition = ts.NewTask()
td.RegistrationInfo.Description = "Does something"
td.Principal.LogonType = TaskLogonType.InteractiveToken
' Add a trigger that will fire the task at this time every other day
Dim dt As DailyTrigger = DirectCast(td.Triggers.Add(New DailyTrigger(2)), DailyTrigger)
dt.Repetition.Duration = TimeSpan.FromMinutes(1)
dt.Repetition.Interval = TimeSpan.FromMinutes(1)
' Add a trigger that will fire every week on Friday
'td.Triggers.Add(New DailyTrigger)
' Add an action that will launch Notepad whenever the trigger fires
td.Actions.Add(New ExecAction("notepad.exe"))
' Register the task in the root folder
Const taskName As String = "Test"
ts.RootFolder.RegisterTaskDefinition(taskName, td)
End Using
End Sub
 

Answers (1)