This project has moved and is read-only. For the latest updates, please go here.

Task Scheduler not running XP machine

Feb 15, 2012 at 6:33 AM


I am using Task Schedular dll, I am creating task using system user it works on win7 and win2k8 machines,

I am creating task using system user because i am running batch file to start my service Every 1 Hrs. can you help me

It gives  this Error 


"XXXXXX.job" (StartSapienceService.bat) 2/14/2012 4:48:00 PM ** ERROR **
The attempt to log on to the account associated with the task failed, therefore, the task did not run.
The specific error is:
0x80041314: The task has been configured with an unsupported combination of account settings and run time options.
Verify that the task's Run-as name and password are valid and try again.
see this code


public static void AddTask(String strTaskName )
            using (TaskService ts = new TaskService())
                // Create a new task definition and assign properties
                TaskDefinition td = ts.NewTask();
                td.RegistrationInfo.Description = @"Keeps your Sapience up to date. If this task is disabled or stopped,your Sapience will not be kept up to date, meaning security vulnerabilities that may arise cannot be fixed and features may not work. This task uninstalls itself when there is no Sapience using it.";

                td.RegistrationInfo.Author = System.Security.Principal.WindowsIdentity.GetCurrent().Name; 

                // Principal
                td.Principal.LogonType = TaskLogonType.ServiceAccount;
                td.Principal.UserId = "SYSTEM";
                //td.Principal.RunLevel = TaskRunLevel.Highest;

                // Settings 
                td.Settings.Enabled = true;
                td.Settings.DisallowStartIfOnBatteries = false;
                td.Settings.StopIfGoingOnBatteries = false;
               // td.Settings.AllowDemandStart = true;
                td.Settings.IdleSettings.IdleDuration = TimeSpan.FromSeconds(600);
                td.Settings.IdleSettings.WaitTimeout = TimeSpan.FromSeconds(3600);
                td.Settings.IdleSettings.StopOnIdleEnd = false;
                td.Settings.IdleSettings.RestartOnIdle = false;
                td.Settings.Hidden = false;
                td.Settings.RunOnlyIfIdle = false;
                td.Settings.WakeToRun = false;
                td.Settings.ExecutionTimeLimit = TimeSpan.FromSeconds(0);
                td.Settings.Priority = System.Diagnostics.ProcessPriorityClass.Normal;

                // Add a trigger that will fire the task at this time every other day
                DailyTrigger dtTemp = new DailyTrigger(1);

                DailyTrigger dt = (DailyTrigger)td.Triggers.Add(dtTemp);
                dt.Repetition.Duration = TimeSpan.FromDays(1);
                dt.Repetition.Interval = TimeSpan.FromHours(1);
                dt.Repetition.StopAtDurationEnd = false;
                dt.StartBoundary = DateTime.Now;
                dt.Enabled = true;

                // Add an action that will launch Notepad whenever the trigger fires
                td.Actions.Add(new ExecAction(_filePath, null, null));

                // Register the task in the root folder
                string taskName = strTaskName;
                ts.RootFolder.RegisterTaskDefinition(taskName, td);