I'm trying to set up a program that would create a task schedule in a remote server. The following code works fine for local machine however when I try it with the remote server, it throws up the following error.
System.Runtime.InteropServices.COMException: 'The request is not supported. (Exception from HRESULT: 0x80070032)'
void SetupDailyTask()
{
using (TaskService ts = new TaskService("servername.us.xxxxxdomain.com",
@"domainname\username","domainname","password"))
{
//Task tsk = ts.GetTask("DailyTask");
//if (tsk != null) { ts.RootFolder.DeleteTask("DailyTask"); }
//DateTime dt = DateTime.Now;
//TimeSpan tsp = new TimeSpan(12, 44, 0);
//dt = dt.Date + tsp;
//ts.Execute("notepad.exe").Once().Starting(dt).AsTask("DailyTask");
}
}
I've already tested the credentials, server name etc and they work just fine with the Remote Desktop Connection. I'm using the Microsoft.Win32.TaskScheduler
namespace. Any help with this is much appreciated.
According to the Microsoft documentation, this is only supported on Windows Server 2008 or newer.
One option I found was provided by Microsoft, but I've not tried it.
User contributions licensed under CC BY-SA 3.0