Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Windows XP SP3 System Account.

$
0
0
You cannot combine RunOnlyIfLoggedOn and service accounts. You also have a problem with V1 on how you are using Principal. You will get a more consistent result by putting all the account information for new tasks in the registration:
using (TaskService ts = new TaskService())
{
    isVersionOne = ts.HighestSupportedVersion < new Version(1, 2);

    TaskDefinition td = ts.NewTask();
    td.RegistrationInfo.Description = "Task";
    td.RegistrationInfo.Author = "Me";
    td.Triggers.Add(new DailyTrigger
    {
        StartBoundary = DateTime.Now,
        DaysInterval = 2
    });

    td.Actions.Add(new ExecAction(@"C:\ConsoleApplication.exe"));
    var task = ts.RootFolder.RegisterTaskDefinition("Test Task", td, TaskCreation.Create, "SYSTEM", null, TaskLogonType.ServiceAccount, null);
}

Viewing all articles
Browse latest Browse all 2206

Trending Articles