Hi,
I want to create a task scheduler on weekly basis. i want my exe file run on Monday & Tuesday around 11:00 AM in morning.
How to do the code
below is code
I want to create a task scheduler on weekly basis. i want my exe file run on Monday & Tuesday around 11:00 AM in morning.
How to do the code
below is code
Private Sub TaskRunSheduler()
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.FromHours(11)
dt.Repetition.Interval = TimeSpan.FromHours(0)
' Add a trigger that will fire every week on Friday
' below i will put my exe file
td.Actions.Add(New ExecAction("D:\Atn.exe"))
' Register the task in the root folder
Const taskName As String = "RunWeeklyBasis"
ts.RootFolder.RegisterTaskDefinition(taskName, td)
End Using
End Sub