Cannot create task running as Service Account

Nov 10, 2011 at 4:19 PM
Edited Nov 10, 2011 at 4: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 4: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!