How to detect batch logon disabled on RegisterTaskDefinition

0

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.

c#
asked on Stack Overflow Sep 14, 2017 by Milkin Vladimir

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0