I am looking for a possibility to connect the C# DateTimePicker
with the
Task Scheduler Library. Looking through the documentation didn't enlighten
my mind. Does anybody have or found a solution for this kind of matter?
Normally it is initialized by:
new TaskService().AddTask
("ITW Backup", new TaskTriggerType { Once },
new ExecAction("Backup.exe", "C:\\Backup\\ini.ini", null));
But even the {once}
statement out of the documentation is giving me a hard time.
The solution was fairly simple :)
dateTimePicker1.Format = DateTimePickerFormat.Time;
TaskService ts = new TaskService();
TaskDefinition td = ts.NewTask();
Trigger t = new TimeTrigger();
t.StartBoundary = System.DateTime.Now.Date +this.dateTimePicker1.Value.TimeOfDay;
td.Triggers.Add(t);
//string path1 = Path.GetDirectoryName(Application.ExecutablePath);
string path1 = Desktop + @"\Desktop\Release\ITWBackup.exe";
td.Actions.Add(new ExecAction(path1, null, null));
ts.RootFolder.RegisterTaskDefinition("ITWBackup", td);
ts.BeginInit();