// Get the service on the local machine
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Daily trigger";
td.Principal.LogonType = TaskLogonType.InteractiveToken;
// Add a trigger that will fire the task at this time every other day
td.Triggers.Add(new DailyTrigger { StartBoundary = DateTime.Today.AddHours(9) });
// Add an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction("C:\\Launcher.exe"));
// Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition("Scheduler", td);
}
↧
New Post: Create daily 9h Task Schedule in Windows 7
↧