dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.21k stars 191 forks source link

Tasks which have been registered previously with stored passwords must use the TaskFolder.RegisterTaskDefinition method for updates. #834

Closed rubens-farias closed 4 years ago

rubens-farias commented 4 years ago

I can't set a local task to enabled/disabled as it returns the error message: "Tasks which have been registered previously with stored passwords must use the TaskFolder.RegisterTaskDefinition method for updates."

Steps to reproduce the behavior: var enabled = Configuration.Enabling; var tasks = TaskService.Instance.FindAllTasks( task => task.Folder.Name.Equals(Configuration.MesFolderName, ignoreCase) && Configuration.Filter.IsMatch(task.Name)); foreach (var task in tasks) { try { task.Definition.Settings.Enabled = enabled; task.RegisterChanges(); } catch (Exception ex) { Logger.Error(ex); } }

Environment:

That task have a saved password and I would like to do not have to store it locally for creating a new task.

dahall commented 4 years ago

There are multiple issues logged with this resolution. Here it is again:

foreach (var t in tasks)
   t.Enabled = enabled;
rubens-farias commented 4 years ago

Hi @dahall, thanks for your reply; I've tried to look for that error message before asking here, but nothing came up.

I've made the change and noticed the RegisterChanges call isn't necessary, that was the mistake. Thanks!

--Rubens