Quantcast
Viewing all articles
Browse latest Browse all 2206

Commented Unassigned: Error using RegisterTaskDefinition on Window10 Professional [12169]

______Error using RegisterTaskDefinition on Window10 Proffessional______

When calling "RegisterTaskDefinition", the error I am getting is:

the task xml contains a value which is incorrectly formatted or out of range
Exception from HResult:0x80041318

Any help is appreciated.
Comments: ** Comment from web user: fedelic **

I have the same problem with that method. The program executes correctly in Windows 7 and Windows 8.1 but in Windows 10 throws this Exception: " _A password must be supplied when specifying TaskLogonType.Password or TaskLogonType.InteractiveTokenOrPassword or TaskLogonType.S4U from another account"_

I have updated the the "Task Scheduler Managed Wrapper" from Nuget with last release 2.4.2 but, the problem persist.

Anyone can help me?

This is the code:

//Trigger definition
DailyTrigger dailyTr = new DailyTrigger(daysInterval);
dailyTr.Enabled = true;
dailyTr.StartBoundary = startTaskBoundary;
dailyTr.Repetition.Interval = repetitionInterval;
dailyTr.Repetition.StopAtDurationEnd = true;
dailyTr.Repetition.Duration = executionDurationTime;
dailyTr.EndBoundary = endTaskBoundary;
dailyTr.ExecutionTimeLimit = executionDurationTime.Subtract(TimeSpan.FromMinutes(1));

//Task definition
TaskDefinition taskDefinition = taskService.NewTask();
taskDefinition.Settings.WakeToRun = true;
taskDefinition.Settings.AllowHardTerminate = true;
taskDefinition.Settings.RunOnlyIfNetworkAvailable = true;
taskDefinition.Settings.StopIfGoingOnBatteries = true;
taskDefinition.Settings.Priority = System.Diagnostics.ProcessPriorityClass.High;
taskDefinition.Principal.UserId = Environment.UserName;
taskDefinition.Principal.RunLevel = TaskRunLevel.Highest;
taskDefinition.Principal.LogonType = TaskLogonType.Password;
taskDefinition.RegistrationInfo.Description = description;

taskDefinition.RegistrationInfo.Author = Environment.UserName;
taskDefinition.Triggers.Add(dailyTr);
taskDefinition.Actions.Add(new ExecAction(Path.GetFileName(fullNameExe), null, Path.GetDirectoryName(fullNameExe)));
//Registers the task to the taskFolder
taskFolder.RegisterTaskDefinition(nameTask, taskDefinition,TaskCreation.CreateOrUpdate,Environment.UserName,null, TaskLogonType.S4U);


Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>