COMException connecting to Windows 8\Windows 2012 Task Scheduler remotely

3

I am using TaskService (interop of COM task scheduler 1.1 type library) class running on Windows server 2008 system to connect remotely to Task Scheduler on another Windows server system. The relevant code snippet follows:

var ts = new TaskService(IP address, userId, domain, password);
foreach (Task task in ts.RootFolder.Tasks)
{
    Console.Writeline(task.Definition.Principal.UserId);
}

This works great when the target is Windows 2008 and Windows 7, but with Windows server 2012 & windows 8 I get the following COM exception:

"The task XML contains a value which is incorrectly formatted or out of range. (Exception from HRESULT: 0x80041318)"

I examined the Task's Xml property returned above. The only difference I see is that it is Task version=\"1.4\" for Windows 2012, but Task version=\"1.3\" or lower when remote system is Windows 2008 or Windows 7."

The property accessor task.Definition is throwing the exception:

System.Runtime.InteropServices.COMException (0x80041318): The task XML contains
a value which is incorrectly formatted or out of range. (Exception from HRESULT:
 0x80041318)
   at TaskScheduler.IRegisteredTask.get_Definition()

The ITaskSchedulerService interface uses XML to define tasks. In windows 8 and Windows 2012 they use new Task Scheduler Remoting Protocol (version 1.4), Which is not compatible with oldest Windows OS that use version 1.2- 1.3.

Is there a way to target Win 2012 or Win8 Task Scheduler remotely from Windows 2008 system?

c#
.net
windows-8
scheduled-tasks
windows-server-2012
asked on Stack Overflow Mar 6, 2013 by user719280 • edited Mar 11, 2013 by user719280

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0