Hi Tomasz, > It is a correct switch, but using it prevents passing a proper exit code > to WPKG Client. No, it does not. If used in the "topmost" script (not a sub-script invoked via call) it will also terminate cmd.exe with the given code. > Whether /b is used or not, it will exit a script with certain exit code. Yes, but using the /b switch it will exit only the inner script currently running. > In other words, without /b, cmd.exe will terminate with exit code > specified in "exit" command. True, but there is no possibility to continue a script which has called the one which exits without using the /b switch. > With /b, cmd.exe will exit with exit code 0. No, it will exit with the exit code specified. 'exit /b 2' will exit with code 2. > When we want to "fetch" the exit code in WPKG Client, /b switch must not > be used. Be assured it can be used - I use this very frequently. An example can prove this. "script1.cmd": @echo off call script2.cmd echo exit code: %errorlvel% pause exit 1 "script2.cmd": @echo off exit /b 2 1. Test, calling script1.cmd from a CMD prompt: - the term "exit code: 2" is printed - after pressing enter at the 'pause' prompt the script closes down the window (including the one where you typed "script1.cmd"). NOTE: Closing the CMD window is normal if oyu double-click the cmd file, however when invoking "script1.cmd" from a CMD prompt then you most probably do not want to exit it. I never understood why Windows is behaving like this. Here actually a sub-command exits its parent - totally strange, such a thing will never happen on a unix shell. - However, the exit code of script1.cmd will be code 1. 2. Test, calling script2.cmd, entering "echo %errorlevel% immediately afterwards - an errorlevel of 2 is printed So "script2.cmd" exits properly with exit code 2 - which can be evaluated by WPKG (verified several times). The only difference is if you're going to change your script - or write another script which has to invoke "script1.cmd". Imagine the following script: @echo off echo Invoking script 1 call script1.cmd echo doing something else call scriptxy.cmd exit /b 0 In such case everything after calling script1.cmd will _NEVER_ be executed as script 1 totally closes down CMD.EXE. Yes, this is either a bug on the CMD shell or just annoying design. Perhaps that happens on Vista only (I just tested it here on Vista x64 now). So scripts should never exit using 'exit <code>' from my point of view. Using 'exit /b <code>' perfectly serves the purpose and works in every case (no matter if your script is the topmost or one of the called ones. br, Rainer |