We have a program that inserts a weekly scheduled task for performing a local backup.
The event is generated using class WeeklyTrigger
and inserted in windows task scheduler. The bulk code of registration is:
var wt = new WeeklyTrigger
{
DaysOfWeek = weekday,
StartBoundary = startDate,
Enabled = true
};
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Backup";
td.Triggers.Add(wt);
td.Actions.Add(Application.ExecutablePath, arg);
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
ts.RootFolder.RegisterTaskDefinition(name, td);
}
This works correclty but inserts the scheduled task with option Syncronize across time zones
enabled which sets scheduled time as UTC. With this configuration when Daylight saving time starts (or ends) the task running time is not updated and this results in 1 hour offset from the expected running time.
Disabling Syncronize across time zones
option let the scheduled task to run using local time.
Edit, to be more clear If we schedule the task for monday at 10:00 CET with daylight saving time and then when daylight saving time is removed the set time stays in UTC and the task is then started on monday at 09:00 CET. We want to avoid this because users plans their backup at the end of their work week and an hour before or after can make a huge difference in data integrity.
Is it possibile to create the scheduled task without the Syncronize across time zones
options programmatically? Is there some specific documentation that we can check?