Reputation: 47
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!
Upvotes: 2
Views: 3051
Reputation: 184
One solution for your issue is you can use Task Scheduler Managed Wrapper, download at https://taskscheduler.codeplex.com/.
This is a very powerful wrapper that can work with Windows Task Scheduler and can handle the issue "Access is denied" also.
Upvotes: 1
Reputation: 47
Finally I got the solution, at least for develop time...I have to run Visual Studio as administrator. In this way I can modify tasks in whatever folder.
Upvotes: 0