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

Scheduling a remote task using TaskLogonType.Password results in COMException

Sep 20, 2012 at 7:15 PM
Edited Sep 20, 2012 at 7:15 PM

I'm running the following code

ts.RootFolder.RegisterTaskDefinition("Test", td, TaskCreation.Create, "domain\\user", "password", TaskLogonType.Password);

I get a COMException with the following message:

A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520)

The only solution I seem to be coming across if the following:

However, the GPO setting is disabled and I'm still receiving that error. If I change the TaskLogonType to InteractiveTokenOrPassword, it will create the task, but I absolutely require that the task be able to run when the user is not logged in.


Sep 21, 2012 at 5:09 PM

Can you create the task manually using the desired settings in the Task Scheduler applet under "Start | All Program | Accessories | System Tools"?

Jun 8, 2016 at 2:29 PM
Edited Jun 10, 2016 at 10:19 PM
You can change the setting for that network access security policy in the registry as well if disabling it in local security isn't working.