Hi All,
I've been trying to write a COM+ component in VC++ that will add tasks to
the Windows Task Scheduler that it gets from a private Message Queue.
I've gone through all the documentation and examples in the MSDN Library for
Task Scheduler but I'm flumoxed by an error when trying to add a task to the
scheduler.
The code in question is:
/////////////////////////////////////////////////////////////////
// Call ITaskScheduler::NewWorkItem to create new task.
/////////////////////////////////////////////////////////////////
LPCWSTR pwszTaskName;
ITask *pITask;
IPersistFile *pIPersistFile;
pwszTaskName = L"Test Task";
hr = pITS->NewWorkItem(pwszTaskName, // Name of task
CLSID_CTask, // Class identifier
IID_ITask, // Interface identifier
(IUnknown**)&pITask); // Address of task interface
pITS->Release(); // Release object
if (FAILED(hr))
{
CoUninitialize();
fprintf(stderr, "Failed calling NewWorkItem, error = 0x%x\n",hr);
return 1;
}
When I run this, hr is returning 0x8007005, the very annoying catch-all
Access Denied error.
I tried to change the LogOn for the Task Scheduler service to a Domain
Account with local administrator rights, but restarting the service brings
up a error:
"Error 1709: The account specified for this service is different from the
account specified for other services running in the same process."
Maybe because the executable is svchost.exe, and there are a lot of
processes running with that one.
Anyway, the error I am seeing is probably indicitive of some other
underlying security or permissions problem that may cause more difficulties
further down the road, so I'm focused on getting this method working as it
is, rather than looking at WMI, the TaskScheduler.dll from Site Server, or
third party products.
Any help with this would be welcome.
Regards...Andrew