This project has moved. For the latest updates, please go here.

Error during Enabling/Disabling task

Topics: Errors
May 4, 2013 at 9:47 AM
(Win8 x64, .NET 4.0) I get the following error when I try to enable or disable a task using VB.NET:

"An unhandled exception of type 'System.Security.SecurityException' occurred in Microsoft.Win32.TaskScheduler.dll

Additional information: Tasks which have been registered previously with stored passwords must use the TaskFolder.RegisterTaskDefinition method for updates."

The code I use is very simple:
Dim t As Task = ts.GetTask(originaltask.Path)
            t.Enabled = True
            t.RegisterChanges()
I don't want to prompt for user name & password for enabling/disabling tasks.

What can I do?
Coordinator
May 4, 2013 at 5:35 PM
Those are restrictions from the Microsoft library. Once a task is registered with a stored password, it must have that password specified with each re-registration. The RegisterChanges method cannot handle this type of update.