I have created a task scheduler and set its trigger time fixed e.g. daily-5:00 pm, but I want to trigger that event when system start or boot. Please help me with code if you have any example.
Thanks in Advance.
Code :------------------------------------------------------
public static void CreateTask()
{
using (TaskService task = new TaskService())
{`enter code here`
TaskDefinition taskdDef = task.NewTask();
taskdDef.RegistrationInfo.Description = "Does something";
taskdDef.RegistrationInfo.Documentation = "http://www.mysite.com";
taskdDef.Settings.ExecutionTimeLimit = new TimeSpan(0, 10, 0);
taskdDef.Settings.AllowDemandStart = true;
taskdDef.Actions.Add(new ExecAction(@"D:\Myfolder\bin\SGSclient.exe", "yourArguments", null));
task.RootFolder.RegisterTaskDefinition("YourTask", taskdDef);
}
}
You should make a Windows Service.
Using the Task Scheduler Manager Library from CodePlex, you could write this
You can add it to the registry as a start task. See here.
2000, XP
Start -> Settings -> Control Panel -> Scheduled Tasks
Open the properties of the task.
Open the "Schedule" tab.
From the "Schedule Task" pull-down select "At System Startup".
Vista
Start -> Settings -> Control Panel -> Administrative Tools -> Task Scheduler
Open the properties of the task.
Open the "Triggers" tab, then edit or create a trigger.
From the "begin the task" pulldown select "At Startup".