Recently I wanted to create an app that involved the Windows Task Scheduler. During the process I wanted to handle all of the possible Result Codes and finding the values of them was a bear. I figure I would add them here so at least there is one more reference out there.
Public Enum TaskResultCodes
SCHED_S_TASK_READY = &H00041300
SCHED_S_TASK_RUNNING = &H00041301
SCHED_S_TASK_DISABLED = &H00041302
SCHED_S_TASK_HAS_NOT_RUN = &H00041303
SCHED_S_TASK_NO_MORE_RUNS = &H00041304
SCHED_S_TASK_NOT_SCHEDULED = &H00041305
SCHED_S_TASK_TERMINATED = &H00041306
SCHED_S_TASK_NO_VALID_TRIGGERS = &H00041307
SCHED_S_EVENT_TRIGGER = &H00041308
SCHED_E_TRIGGER_NOT_FOUND = &H80041309
SCHED_E_TASK_NOT_READY = &H8004130A
SCHED_E_TASK_NOT_RUNNING = &H8004130B
SCHED_E_SERVICE_NOT_INSTALLED = &H8004130C
SCHED_E_CANNOT_OPEN_TASK = &H8004130D
SCHED_E_INVALID_TASK = &H8004130E
SCHED_E_ACCOUNT_INFORMATION_NOT_SET = &H8004130F
SCHED_E_ACCOUNT_NAME_NOT_FOUND = &H80041310
SCHED_E_ACCOUNT_DBASE_CORRUPT = &H80041311
SCHED_E_NO_SECURITY_SERVICES = &H80041312
SCHED_E_UNKNOWN_OBJECT_VERSION = &H80041313
SCHED_E_UNSUPPORTED_ACCOUNT_OPTION = &H80041314
SCHED_E_SERVICE_NOT_RUNNING = &H80041315
SCHED_E_UNEXPECTEDNODE = &H80041316
SCHED_E_NAMESPACE = &H80041317
SCHED_E_INVALIDVALUE = &H80041318
SCHED_E_MISSINGNODE = &H80041319
SCHED_E_MALFORMEDXML = &H8004131A
SCHED_S_SOME_TRIGGERS_FAILED = &H0004131B
SCHED_S_BATCH_LOGON_PROBLEM = &H0004131C
SCHED_E_TOO_MANY_NODES = &H8004131D
SCHED_E_PAST_END_BOUNDARY = &H8004131E
SCHED_E_ALREADY_RUNNING = &H8004131F
SCHED_E_USER_NOT_LOGGED_ON = &H80041320
SCHED_E_INVALID_TASK_HASH = &H80041321
SCHED_E_SERVICE_NOT_AVAILABLE = &H80041322
SCHED_E_SERVICE_TOO_BUSY = &H80041323
SCHED_E_TASK_ATTEMPTED = &H80041324
SCHED_S_TASK_QUEUED = &H00041325
SCHED_E_TASK_DISABLED = &H80041326
SCHED_E_TASK_NOT_V1_COMPAT = &H80041327
SCHED_E_START_ON_DEMAND = &H80041328
''' Pass the task result code to get the message associated with the result
''' Result Code to get text for
''' Message of Result Code
Function ReturnResultCodeString(iLong As Integer) As String
Select Case iLong
ReturnResultCodeString = "The task is ready to run at its next scheduled time."
Case TaskResultCodes.SCHED_S_TASK_RUNNING ' &H00041301
ReturnResultCodeString = "The task is currently running."
Case TaskResultCodes.SCHED_S_TASK_DISABLED ' &H00041302
ReturnResultCodeString = "The task will not run at the scheduled times because it has been disabled."
Case TaskResultCodes.SCHED_S_TASK_HAS_NOT_RUN ' &H00041303
ReturnResultCodeString = "The task has not yet run."
Case TaskResultCodes.SCHED_S_TASK_NO_MORE_RUNS ' &H00041304
ReturnResultCodeString = "There are no more runs scheduled for this task."
Case TaskResultCodes.SCHED_S_TASK_NOT_SCHEDULED ' &H00041305
ReturnResultCodeString = "One or more of the properties that are needed to run this task on a schedule have not been set."
Case TaskResultCodes.SCHED_S_TASK_TERMINATED ' &H00041306
ReturnResultCodeString = "The last run of the task was terminated by the user."
Case TaskResultCodes.SCHED_S_TASK_NO_VALID_TRIGGERS ' &H00041307
ReturnResultCodeString = "Either the task has no triggers or the existing triggers are disabled or not set."
Case TaskResultCodes.SCHED_S_EVENT_TRIGGER ' &H00041308
ReturnResultCodeString = "Event triggers do not have set run times."
Case TaskResultCodes.SCHED_E_TRIGGER_NOT_FOUND ' &H80041309
ReturnResultCodeString = "A task's trigger is not found."
Case TaskResultCodes.SCHED_E_TASK_NOT_READY ' &H8004130A
ReturnResultCodeString = "One or more of the properties required to run this task have not been set."
Case TaskResultCodes.SCHED_E_TASK_NOT_RUNNING ' &H8004130B
ReturnResultCodeString = "There is no running instance of the task."
Case TaskResultCodes.SCHED_E_SERVICE_NOT_INSTALLED ' &H8004130C
ReturnResultCodeString = "The Task Scheduler service is not installed on this computer."
Case TaskResultCodes.SCHED_E_CANNOT_OPEN_TASK ' &H8004130D
ReturnResultCodeString = "The task object could not be opened."
Case TaskResultCodes.SCHED_E_INVALID_TASK ' &H8004130E
ReturnResultCodeString = "The object is either an invalid task object or is not a task object."
Case TaskResultCodes.SCHED_E_ACCOUNT_INFORMATION_NOT_SET ' &H8004130F
ReturnResultCodeString = "No account information could be found in the Task Scheduler security database for the task indicated."
Case TaskResultCodes.SCHED_E_ACCOUNT_NAME_NOT_FOUND ' &H80041310
ReturnResultCodeString = "Unable to establish existence of the account specified."
Case TaskResultCodes.SCHED_E_ACCOUNT_DBASE_CORRUPT ' &H80041311
ReturnResultCodeString = "Corruption was detected in the Task Scheduler security database; the database has been reset."
Case TaskResultCodes.SCHED_E_NO_SECURITY_SERVICES ' &H80041312
ReturnResultCodeString = "Task Scheduler security services are available only on Windows NT."
Case TaskResultCodes.SCHED_E_UNKNOWN_OBJECT_VERSION ' &H80041313
ReturnResultCodeString = "The task object version is either unsupported or invalid."
Case TaskResultCodes.SCHED_E_UNSUPPORTED_ACCOUNT_OPTION ' &H80041314
ReturnResultCodeString = "The task has been configured with an unsupported combination of account settings and run time options."
Case TaskResultCodes.SCHED_E_SERVICE_NOT_RUNNING ' &H80041315
ReturnResultCodeString = "The Task Scheduler Service is not running."
Case TaskResultCodes.SCHED_E_UNEXPECTEDNODE ' &H80041316
ReturnResultCodeString = "The task XML contains an unexpected node."
Case TaskResultCodes.SCHED_E_NAMESPACE ' &H80041317
ReturnResultCodeString = "The task XML contains an element or attribute from an unexpected name space."
Case TaskResultCodes.SCHED_E_INVALIDVALUE ' &H80041318
ReturnResultCodeString = "The task XML contains a value which is incorrectly formatted or out of range."
Case TaskResultCodes.SCHED_E_MISSINGNODE ' &H80041319
ReturnResultCodeString = "The task XML is missing a required element or attribute."
Case TaskResultCodes.SCHED_E_MALFORMEDXML ' &H8004131A
ReturnResultCodeString = "The task XML is malformed."
Case TaskResultCodes.SCHED_S_SOME_TRIGGERS_FAILED ' &H0004131B
ReturnResultCodeString = "The task is registered, but not all specified triggers will start the task."
Case TaskResultCodes.SCHED_S_BATCH_LOGON_PROBLEM ' &H0004131C
ReturnResultCodeString = "The task is registered, but may fail to start. Batch logon privilege needs to be enabled for the task principal."
Case TaskResultCodes.SCHED_E_TOO_MANY_NODES ' &H8004131D
ReturnResultCodeString = "The task XML contains too many nodes of the same type."
Case TaskResultCodes.SCHED_E_PAST_END_BOUNDARY ' &H8004131E
ReturnResultCodeString = "The task cannot be started after the trigger end boundary."
Case TaskResultCodes.SCHED_E_ALREADY_RUNNING ' &H8004131F
ReturnResultCodeString = "An instance of this task is already running."
Case TaskResultCodes.SCHED_E_USER_NOT_LOGGED_ON ' &H80041320
ReturnResultCodeString = "The task will not run because the user is not logged on."
Case TaskResultCodes.SCHED_E_INVALID_TASK_HASH ' &H80041321
ReturnResultCodeString = "The task image is corrupt or has been tampered with."
Case TaskResultCodes.SCHED_E_SERVICE_NOT_AVAILABLE ' &H80041322
ReturnResultCodeString = "The Task Scheduler service is not available."
Case TaskResultCodes.SCHED_E_SERVICE_TOO_BUSY ' &H80041323
ReturnResultCodeString = "The Task Scheduler service is too busy to handle your request. Please try again later."
Case TaskResultCodes.SCHED_E_TASK_ATTEMPTED ' &H80041324
ReturnResultCodeString = "The Task Scheduler service attempted to run the task, but the task did not run due to one of the constraints in the task definition."
Case TaskResultCodes.SCHED_S_TASK_QUEUED ' &H00041325
ReturnResultCodeString = "The Task Scheduler service has asked the task to run."
Case TaskResultCodes.SCHED_E_TASK_DISABLED ' &H80041326
ReturnResultCodeString = "The task is disabled."
Case TaskResultCodes.SCHED_E_TASK_NOT_V1_COMPAT ' &H80041327
ReturnResultCodeString = "The task has properties that are not compatible with earlier versions of Windows."
Case TaskResultCodes.SCHED_E_START_ON_DEMAND ' &H80041328
ReturnResultCodeString = "The task settings do not allow the task to start on demand."
ReturnResultCodeString = ""