I'm trying to create a schedule task with the Windows Task Scheduler in C#. It is failing when trying to register the task which is the following line of code:

IRegisteredTask regTask = folder.RegisterTaskDefinition(

The exception I get is as follows:

System.Runtime.InteropServices.COMException: (4,36)ate:01/01/0001 12:00:00 AM

I can't seem to find any good examples anywhere. The articles that I have come across lead me to believe that it might have something to do with the username and password when registering. Here's the code:

public void Register(string path)

//Conntect to scheduler
TaskSchedulerClass scheduler = new TaskSchedulerClass();
scheduler.Connect(null, null, null, null);

//Create Task
ITaskDefinition task = scheduler.NewTask(0);
task.RegistrationInfo.Author = "Homeboy Software";
task.RegistrationInfo.Description = name;
task.RegistrationInfo.Date = created.ToString();
task.Settings.Enabled = isEnabled;
task.Settings.WakeToRun = true;

//Set Task Trigger
ITimeTrigger trigger = (ITimeTrigger)task.Triggers.Create(_TASK_TRIGGER_TYPE2.TASK_TRIGGER_TIME);
trigger.Id = ID;
trigger.Enabled = isEnabled;
trigger.StartBoundary = "2011-01-10T22:30:00";
//trigger.StartBoundary = startTime.ToString(); //Must be ISO 8601 date/time format specified on MSDN as: YYYY-MM-DDTHH:MM:SS(+-)HH:MM.

//Set Task Action
IComHandlerAction action = (IComHandlerAction)task.Actions.Create(_TASK_ACTION_TYPE.TASK_ACTION_COM_HANDLER);
action.Id = ID;

//Register Task
//string taskPath = Path.Combine(path, Homeboy.Default.TasksPathFolder);
ITaskFolder folder = scheduler.GetFolder("\\");
IRegisteredTask regTask = folder.RegisterTaskDefinition(
null, //User
null, //Password
"" //SDDL

//Run Task
IRunningTask runTask = regTask.Run(null);