why scheduled task do not run when time is reached

Topics: Examples
Aug 15, 2016 at 2:46 AM
using (TaskService ts = new TaskService())
            // Create a new task definition and assign properties
            TaskDefinition td = ts.NewTask();
            td.RegistrationInfo.Description = "Does something";
            td.Principal.LogonType = TaskLogonType.InteractiveToken;

            TimeTrigger tTrigger = new TimeTrigger();
            tTrigger.StartBoundary = new DateTime(DateTime.Today.Year, 8, 15, 10, 42, 0);

            // Add a trigger that will fire every week on Friday

            // Add an action that will launch Notepad whenever the trigger fires
            td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));

            // Register the task in the root folder
            const string taskName = "Test";
            ts.RootFolder.RegisterTaskDefinition(taskName, td);
Aug 15, 2016 at 5:55 PM
This appears to be configured properly. Make sure event logging for tasks is turned on and then check the event log. This can be done by going into the Task Scheduler applet, navigating to this tasks, opening its properties, and looking at the History. It should give you failure codes and show the set of events that occurred related to this task.
Marked as answer by dahall on 8/15/2016 at 10:56 AM
Aug 18, 2016 at 6:15 AM
i find that the error log now,

it is due to battery in notebook, need to use AC power supply