This commit is contained in:
Serge
2024-05-15 23:19:20 +02:00
parent 2628695bbc
commit 06b4df29cb

View File

@@ -30,15 +30,22 @@ public class Startup
var task = taskService.RootFolder.AllTasks.FirstOrDefault(t => t.Name == taskName); var task = taskService.RootFolder.AllTasks.FirstOrDefault(t => t.Name == taskName);
if (task != null) if (task != null)
{ {
string strExeFilePath = Application.ExecutablePath.Trim(); try
string action = task.Definition.Actions.FirstOrDefault()!.ToString().Trim();
if (!strExeFilePath.Equals(action, StringComparison.OrdinalIgnoreCase) && !File.Exists(action))
{ {
Logger.WriteLine("File doesn't exist: " + action); string strExeFilePath = Application.ExecutablePath.Trim();
Logger.WriteLine("Rescheduling to: " + strExeFilePath); string action = task.Definition.Actions.FirstOrDefault()!.ToString().Trim();
UnSchedule(); if (!strExeFilePath.Equals(action, StringComparison.OrdinalIgnoreCase) && !File.Exists(action))
Schedule(); {
Logger.WriteLine("File doesn't exist: " + action);
Logger.WriteLine("Rescheduling to: " + strExeFilePath);
UnSchedule();
Schedule();
}
} catch (Exception ex)
{
Logger.WriteLine($"Can't check startup task: {ex.Message}");
} }
} }
} }
} }