I'am trying to modify a scheduled task, manually created in Windows task scheduler, using C# application
using the following code:
rootFolder.RegisterTaskDefinition(taskEdit.Name,
taskDefinition, 6, null, null, _TASK_LOGON_TYPE.TASK_LOGON_NONE, null);
My code works perfectly when I perform this operation in the principal task scheduler folder. But when I try to modify a task in a subfolder I got the error
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
If try to use username and password instead of null as follow:
rootFolder.RegisterTaskDefinition(taskEdit.Name, taskDefinition, 6, "username", "pwd",
_TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD, null);
I got the error below:
(48,4):UserId:
Any ideas? Really Thanks!