Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.