TaskScheduler WMI API - is it possible to modify task?

Dawid W 21 Reputation points
2022-03-30T11:16:31.457+00:00

Hi,

I'm trying to modify scheduled task through WMI Microsoft\Windows\MSFT_ScheduledTask object. However when I call instance Put method to update it I'm getting "Not supported" error. Nothing works. Is it possible at all? Am I doing something wrong?

Below is the code snippet I use for instance update after modification of its one property. Result returned is WBEM_E_NOT_SUPPORTED (0x8004100c).

void WmiObject::Commit()
{
    IWbemCallResultPtr resultObj;
    // IWbemServices* WmiComConnection::ServiceObject()
    // IWbemClassObjectPtr comPtr;
    HRESULT result = comConnection->ServiceObject()->PutInstance(comPtr, WBEM_FLAG_UPDATE_ONLY, NULL, NULL);

    if (FAILED(result))
    {
        throw WmiException("Failed to update a WMI object", result);
    }
}
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,652 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,761 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 85,881 Reputation points
    2022-03-30T12:03:53.1+00:00

    See MSDN samples using ITaskScheduler interface, like Setting Task Property Examples


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.