Exemplo n.º 1
0
        private void setSchedule()
        {
            string applicationPath = System.Reflection.Assembly.GetEntryAssembly().Location + " /silent /update";


            SchedulerResponse response = WindowTaskScheduler
                                         .Configure()
                                         .CreateTask("r1-updater", applicationPath)
                                         .RunDaily()
                                         .RunEveryXMinutes(Properties.Settings.Default.runevery * 60)
                                         .RunDurationFor(new TimeSpan(18, 0, 0))
                                         .SetStartDate(new DateTime(2015, 8, 8))
                                         .SetStartTime(new TimeSpan(8, 0, 0))
                                         .Execute();
        }
Exemplo n.º 2
0
        private static void ActivateTaskScheduler()
        {
            var response = WindowTaskScheduler.Configure()
                           .CreateTask("WatchDog", $@"{Environment.CurrentDirectory}\WD.Executeable.exe")
                           .RunDaily()
                           .RunEveryXMinutes(60)
                           .RunDurationFor(new TimeSpan(8, 30, 0))
                           .SetStartDate(new DateTime(2020, 03, 15))
                           .SetStartTime(new TimeSpan(8, 0, 0))
                           .Execute();

            if (!response.IsSuccess)
            {
                Console.WriteLine($"Error while creating task. {response.ErrorMessage}. Press any key to continue...");
                Console.ReadKey();
            }
            else
            {
                Properties.Settings.Default.TaskActivated = true;
                Properties.Settings.Default.Save();
            }
        }
Exemplo n.º 3
0
 private static void DeactivateTaskScheduler()
 {
     WindowTaskScheduler.Configure().DeleteTask("WatchDog");
     Properties.Settings.Default.TaskActivated = false;
     Properties.Settings.Default.Save();
 }
Exemplo n.º 4
0
 private void deleteSchedule()
 {
     WindowTaskScheduler
     .Configure().DeleteTask("r1-updater");
 }