3.2.5.4.17 SchRpcGetLastRunInfo (Opnum 16)

The SchRpcGetLastRunInfo method MUST return information about the task's last run.

 HRESULT SchRpcGetLastRunInfo(
   [in, string] const wchar_t* path,
   [out] PSYSTEMTIME pLastRuntime,
   [out] DWORD* pLastReturnCode
 );

path: MUST contain the full path to a task using the format specified in section 2.3.11.

pLastRuntime: The server MUST return an error if this parameter is NULL. The server MUST return the time when the task last started running, or zero if the task has never started.

pLastReturnCode: The server MUST return an error if this parameter is NULL. The server MUST return the exit code from the task's last execution, or zero if the task has never finished execution.

Return Values: For more information about return codes, see section 2.3.14, or Win32 Error Codes in [MS-ERREF] section 2.1.

Upon receipt of the SchRpcGetLastRunInfo call that requires the server to return the info of the last instance of a task, the server MUST:

  • Return E_INVALIDARG if any of the following statements are true:

    • The path parameter is NULL.

      The pLastRuntime parameter is NULL.

      The pLastReturnCode parameter is NULL.

    Note When passing NULL as a value for parameters, behavior can change based on the RPC Runtime Check. See RPC Runtime Check Notes (section 3.3).

  • Return the value 0x8007007B, the HRESULT form of the Win32 error ERROR_INVALID_NAME, if the specified path is not in the format specified in section 2.3.11.

  • Return the value 0x80070003, the HRESULT form of the Win32 error ERROR_PATH_NOT_FOUND, if the specified path does not exist on the server in the XML task store.

  • Return the HRESULT form of the Win32 error ERROR_FILE_NOT_FOUND if the  specified task does not exist on the server in the XML task store.

  • Return E_ACCESSDENIED if the caller does not have read access to the task.

  • Retrieve the last runtime and exit code associated with the task in the task store, and:

    • Return the last runtime in the pLastRuntime parameter.

    • Return the exit code in the pLastReturnCode parameter.

  • Return S_OK.