This project has moved. For the latest updates, please go here.

Not supported on Task scheduler 1.0

Jan 21, 2012 at 11:28 AM

Hi dahall and everyone,

I have a problem when used this task scheduler .  When I develop in windows 7 everything works successful , but when I develop my application in windows XP, application throw new exeception : " MonPropScheduleSystem.CreateFirstSchedule is not supported on Task Scheduler 1.0 "

MonPropScheduleSystem is class library and CreateFirstSchedule is method

this full code :

public static void CreateFirstSchedule(String PathInstallation)
        {
            try
            {
                using (TaskService ts = new TaskService())
                {
                    using (Task t = ts.GetTask(_firstScheduleSystemName))
                    {
                        if (t == null)
                        {
                            TaskDefinition td = ts.NewTask();
                            td.RegistrationInfo.Description = "This is for Automate Daily Sending Email to other account";
                            td.RegistrationInfo.Author = "MonProp";
                            td.Principal.RunLevel = TaskRunLevel.Highest;

                            MonthlyTrigger mTrigger = (MonthlyTrigger)td.Triggers.Add(new MonthlyTrigger());
                            mTrigger.DaysOfMonth = new int[] { 1, 15, 28 };
                            mTrigger.StartBoundary = DateTime.Today.AddHours(8);
                            mTrigger.RandomDelay = TimeSpan.FromHours(3);

                            String InstalltionPath = PathInstallation.Remove(PathInstallation.Length - 1, 1) + "MonProp.Utilities.exe";
                            td.Actions.Add(new ExecAction(InstalltionPath, "-d -n", null));

                            const string taskName = _firstScheduleSystemName;
                            ts.RootFolder.RegisterTaskDefinition(taskName, td, TaskCreation.CreateOrUpdate, "SYSTEM", null, TaskLogonType.ServiceAccount, null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

any ideas? 

Thank you..

Coordinator
Jan 21, 2012 at 5:25 PM
Edited Jan 21, 2012 at 5:28 PM

td.Principal.RunLevel and mTrigger.RandomDelay are not supported on systems prior to Vista. See the Examples Page link under the Documentation tab for the "complex example". It will show you how to detect the version of the Task Scheduler and only call those properties when they are supported.

Jan 22, 2012 at 1:46 AM
dahall wrote:

td.Principal.RunLevel and mTrigger.RandomDelay are not supported on systems prior to Vista. See the Examples Page link under the Documentation tab for the "complex example". It will show you how to detect the version of the Task Scheduler and only call those properties when they are supported.

Thank for your explanation.. Now, my problem already fixed..

Thank you.. :D