I use Microsoft.Win32.TaskScheduler for creating new Task in Windows Scheduler.
Code like this:
using (TaskService ts = new TaskService())
{
// ...
ts.RootFolder.RegisterTaskDefinition(
taskName, td, TaskCreation.Create, userId, password,
TaskLogonType.Password);
}
My problem that I cant detect situation when userId has no rights for batch logon.
In Windows API this situation detected by HRESULT from RegisterTaskDefinition as SCHED_S_BATCH_LOGON_PROBLEM (0x0004131C).
But in c# lib this result is hidden and no exception thrown.
User contributions licensed under CC BY-SA 3.0