Código:
string Dia = comboBox2.SelectedItem.ToString();
short hra = Convert.ToInt16(textBox4.Text);
short min = Convert.ToInt16(textBox3.Text);
using (ScheduledTasks Tareas = new ScheduledTasks())
{
Task tarea = Tareas.CreateTask("Ejecutar secador de botas");
tarea.ApplicationName = @"C:\Program Files (x86)\Fishken SB\SecadorDeBotas \SecadorBotas.exe";
tarea.Comment = "Tarea que ejecuta programa secador de botas";
tarea.Creator = "USER";
tarea.Priority = System.Diagnostics.ProcessPriorityClass.Normal;
switch (Dia)
{
case "Lunes":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Monday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
case "Martes":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Tuesday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
case "Miercoles":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Wednesday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
case "Jueves":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Thursday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
case "Viernes":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Friday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
case "Sabado":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Saturday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
case "Domingo":
tarea.Triggers.Add(new WeeklyTrigger(hra, min, DaysOfTheWeek.Sunday));
tarea.Save();
MessageBox.Show("Configuración guardada!!");
break;
}
}