Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Exit Code ExitCode Result Return
Every function in WinBatch returns a result. A successful command returns a 1, while an unsuccessful script returns a ZERO value or an error. However, well-behaved scripts should return a ZERO exit code upon successful completion. WinBatch always returns a zero, unless otherwise specified.
You can use the IntControl 1000 function to modify the exit code. The last IntControl 1000 command executed in the script determines the exit status. The Exit Code values should be an integer in the 0 - 255 range.
When a script ends with an exit with no IntControl 1000 the exit code will be ZERO.
;{WILCOMMANDS} Exit ; Exit code will be zero
When a script ends with no exit with no IntControl 1000 the exit code will be ZERO.
;{WILCOMMANDS} ; Exit code will be zero
When a script ends calling IntControl 1000 the exit code will be the value specified in the last IntControl 1000 call.
exitcode = AskLine( "Hello", "Enter Exit Code", "13") IntControl( 1000, exitcode, 0, 0, 0) ExitHere's another example:
;*************************************************************************** ;** ;** exit code 123 on failure and zero for success ;** ;*************************************************************************** ; Set exit code to some known value until code completes exitcode = 123 ; assume failure IntControl(1000, exitcode, 0, 0, 0) ;{WILCOMMANDS} ; Set exit code back to ZERO just before exit exitcode = 123 ; assume failure IntControl(1000, 0, 0, 0, 0) Exit
Article ID: W17510
Filename: Exit Codes in WinBatch.txt
File Created: 2011:03:18:12:55:58
Last Updated: 2011:03:18:12:55:58