Here's my simple repro BAT file (also CC'd to Mike Whalen)...
=====================================
@echo wscript.quit wscript.arguments(0) > test.vbs
cscript.exe test.vbs 99
@echo errorlevel = %ERRORLEVEL%
cscript.exe test.vbs
@echo errorlevel = %ERRORLEVEL%
del test.vbs
=====================================
--
Michael Harris
Microsoft.MVP.Scripting
"Wayne Erfling" <wayne....@compaq.com> wrote in message news:O9won16ZBHA.1752@tkmsftngp07...
@echo wscript.echo(wscript.arguments(0)) wscript.quit
(wscript.arguments(0)) > test.vbs
then the following output ensues at runtime:
C:\scripts\SCRIPT~1\gradings\test.vbs(1, 37) Microsoft
VBScript compilation error: Expected end of statement
errorlevel = 1
All errors are equal but some are more equal than others.
Charles
>....
>if (HaveError)
> WScript.quit(62);
>....
>// normal end of script; no error
>
>with a command file such as the following:
>
>CSCRIPT.EXE myscriptfile.js
>IF ERRORLEVEL 1 GOTO PROCESSERROR
>REM assume script must have succeeded
>
>there are potentially many cases where ERROR will be
equal to ZERO, even though the script has in fact failed.
>
>I urge Microsoft to fix CSCRIPT.EXE, so that ERRORLEVEL
of zero will only be returned when WScript.quit(n) is
called with n=0, or when the script comes to a normal
conclusion with no errors.
>
>---Wayne Erfling (Compaq Computer)
>
>
>.
>
So it seems that:
- an explicit wscript.quit nnn *is* detectable as ERRORLEVEL nnn
- a compilation error is detectable as ERRORLEVEL 1
- an unhandled runtime error is *not* detectable via ERRORLEVEL
The behavior seems to be the same for both cscript and wscript as hosts.
--
Michael Harris
Microsoft.MVP.Scripting
--
"Charles Long" <charle...@eulergroup.com> wrote in message news:698901c16836$a7bc6930$a5e62ecf@tkmsftngxa07...