using (var ts = new Microsoft.Win32.TaskScheduler.TaskService())
{
// Create a new task definition and assign properties
var td = ts.NewTask();
td.RegistrationInfo.Description = input.Description;
// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(new Microsoft.Win32.TaskScheduler.DailyTrigger { DaysInterval = 2, StartBoundary = DateTime.Now.AddMinutes(1) });
// Create an action that will launch Notepad whenever the trigger fires
//td.Actions.Add(new Microsoft.Win32.TaskScheduler.ExecAction(qsClient, @"/key:" + retVal.ToString(), null));
td.Actions.Add(new Microsoft.Win32.TaskScheduler.ExecAction("dir.exe","C:\\temp\\", null));
// Register the task in the root folder
//string taskName = input.OutputName.Replace("%DATE%", retVal.ToString());
string taskName = "MyDirectory";
ts.RootFolder.RegisterTaskDefinition(taskName, td);
}