Closed puzzled-paradox closed 3 years ago
This is curious. I can only guess that there is a task on the machine that, when its XML is requested, returns one without a version tag. The code can be found here.
It could be the order or way that you're calling the methods on the retrieved tasks. Do you mind sending your code for the two examples above?
Sure here is the code from the examples above.
I've run the following code without errors on my Windows 10 21H1 19043.1110 system with lib version 2.9.2.
foreach (Task t in TaskService.Instance.AllTasks)
{
foreach (ExecAction action in t.Definition.Actions.OfType<ExecAction>().
Where(a => string.Equals(a.Path, cmdPath, StringComparison.InvariantCultureIgnoreCase) &&
string.Equals(a.Arguments, args, StringComparison.InvariantCultureIgnoreCase)))
{
t.Definition.Settings.ExecutionTimeLimit = TimeSpan.FromDays(1);
t.Definition.Settings.StartWhenAvailable = true;
t.RegisterChanges();
}
}
var task = TaskService.Instance.AddTask("Temp", new DailyTrigger(1) { StartBoundary = DateTime.Now },
new ExecAction(commandProgramPath, args), "SYSTEM", null, TaskLogonType.ServiceAccount);
task.Definition.Settings.ExecutionTimeLimit = TimeSpan.FromDays(1);
task.Definition.Settings.StartWhenAvailable = true;
task.Definition.Triggers.Clear();
task.Definition.Settings.Enabled = false;
task.RegisterChanges();
@puzzled-paradox Did the sample code above solve your issue?
Yes, thank you very much
Describe the bug When creating a Windows Scheduled Task, we received an error: " The current version of the native library (1.6) does not support the version of the "[Task Name]" task (0.0)"
To Reproduce Steps to reproduce the behavior: In the particular piece of code we are working with, there are two types of actions performed:
Environment (please complete the following information):