This project has moved and is read-only. For the latest updates, please go here.

Cannot create task running as Service Account

Nov 10, 2011 at 5:19 PM
Edited Nov 10, 2011 at 5:20 PM

When I create a task using the following line:

var task = taskFolder.RegisterTaskDefinition(@"Test", taskDefinition, TaskCreation.CreateOrUpdate, "SYSTEM", null, TaskLogonType.ServiceAccount, null);

I get the following error:

Task Scheduler 2.0 (1.2) does not support setting this property. You must use an InteractiveToken in order to have the task run in the current user session.

My client machine as well as target machine are both Windows 7.


I am uncertain how to "use an InteractiveToken". Please advise.




Nov 10, 2011 at 5:26 PM

Turns out it was another setting that was causing this..

taskDefinition.Settings.RunOnlyIfLoggedOn = false; <- offending (and, it turns out, unnecessary) line


Thanks for looking!