I often run my scripts from a DOS window. Lately I've been trying to pass a status code back to the command line from the main() function of the script. In the .bat file which invokes the script, I have code which tests the value of 'errorlevel' (the built-in DOS variable). Based on the value, I then close the DOS window with either 'exit 0' or 'exit 1'. So far so good. But! The return value of 'errorlevel' is always set to '1' regardless of what I pass it from the script. Has anyone experienced this issue or have a suggestion on how to resolve it?