jeanie77: I just ran the following code without a problem logged into a domain account which is in my local Adminstrators group and had no errors. I have to assume there is something about your runtime environment that is causing the problem. Could it be UAC? Are you running the application "as Administrator"?
using (TaskService ts = new TaskService()) { TaskDefinition td = ts.NewTask(); td.Triggers.Add(new DailyTrigger(2)); td.Actions.Add(new ExecAction("D:\\a.exe")); Task t = ts.RootFolder.RegisterTaskDefinition(taskName, td, TaskCreation.CreateOrUpdate, "SYSTEM", null, TaskLogonType.ServiceAccount); }