I am running the example given on https://taskscheduler.codeplex.com/ on my localPC.
__CODE:__
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
// Create an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));
// Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition(@"Test", td);
}
I see this Behaviour:
* This fails on Windows 10 PC.
* This works on WIndows 7 PC.
* This works on Windows 10 PC if I start the application as "Run as administrator"
Error Details:__
__Microsoft.Win32.TaskScheduler - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))__
at Microsoft.Win32.TaskScheduler.V2Interop.ITaskFolder.RegisterTaskDefinition
at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition
at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition
__I want to run the application without using "Run as Administrator" on windows 10. Can you suggest a fix.__
__
Comments: ** Comment from web user: dahall **
__CODE:__
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
// Create an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));
// Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition(@"Test", td);
}
I see this Behaviour:
* This fails on Windows 10 PC.
* This works on WIndows 7 PC.
* This works on Windows 10 PC if I start the application as "Run as administrator"
Error Details:__
__Microsoft.Win32.TaskScheduler - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))__
at Microsoft.Win32.TaskScheduler.V2Interop.ITaskFolder.RegisterTaskDefinition
at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition
at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition
__I want to run the application without using "Run as Administrator" on windows 10. Can you suggest a fix.__
__
Comments: ** Comment from web user: dahall **
Do you happen to know if, when run, the Troubleshooter either was run as Administrator or if they clicked the option to run as administrator in the first page of the wizard? Failing to do either could product the results you're seeing. Also, unless you are specifically calling the TaskService constructor with all 5 parameters and setting the last parameter to true (forceV1), then only the V2 related items in the Troubleshooter are relevant.
Also, is that happening with other accounts on other Windows 10 installations?