Home > windows server 2003 > How does the "Last Result" column of Scheduled Tasks in Windows Server 2003 get set from a process or script?

How does the "Last Result" column of Scheduled Tasks in Windows Server 2003 get set from a process or script?

August 17Hits:0
Advertisement

The Last Result column of the Scheduled Tasks Window on Windows Server 2003, displays the result of the execution of the .exe, .vbs, .ps1, .bat, .cmd, etc... that has been run at the scheduled time.

There is also an archived history of this value that appears in the Scheduled Tasks Log (Found on the Scheduled Tasks Window under the Advanced->View Log)

Now my question is, if I'm running a scheduled task that is a .exe, .vbs, .ps1, .bat, .cmd, etc... how do I use that process to return a specific Last Result when the process ends?

P.S. If you think this question should be split up into smaller parts since I'm painting pretty broadly with it, just let me know and I'll split it into subsequent smaller questions

Answers

What you are talking about is called an exit code or error level.

The exit code would depend on the programming / scripting language used. For example to send a code 500:

PowerShell, .bat, .cmd = exit 500

VBScript = WScript.Quit 500

In C# you would declare the Main entry point with a return value of type int and then just call return 500;. See http://stackoverflow.com/questions/155610/how-do-i-specify-the-exit-code-of-a-console-application-in-net for an example.

Related Articles

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 1.027 s.