Return code and batch files...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have a simple vbs code that has only the following line in it:
WScript.Quit WScript.Arguments(0)

And a batch file that does the following:

cscript test.vbs 0
echo first test = %errorlevel%
cscript test.vbs 99
echo second test = %errorlevel%
cscript test.vbs 0
echo third test = %errorlevel%

if I run the batch file I get the following expected results:
C:\temp>test.bat

C:\temp>cscript test.vbs 0
C:\temp>echo first test = 0
first test = 0

C:\temp>cscript test.vbs 99
C:\temp>echo second test = 99
second test = 99

C:\temp>cscript test.vbs 0
C:\temp>echo third test = 0
third test = 0

Now, if I run the following command before running test.bat the echo
of errorlevel always returns 0:
c:\temp>set errorlevel=0
c:\temp>test.bat

C:\temp>test.bat

C:\temp>cscript test.vbs 0
C:\temp>echo first test = 0
first test = 0

C:\temp>cscript test.vbs 99
C:\temp>echo second test = 0
second test = 0

C:\temp>cscript test.vbs 0
C:\temp>echo third test = 0
third test = 0

Do you know why if I type set errorlevel=0 that the batch file is not
working correctly? If I type set errorlevel= with nothing after it,
everything works as expected. Can anyone explain this behavior?

And finally... if I have a syntax error in test.vbs (like calling it
without a parameter) it returns 0 no matter what, is this correct?
.



Relevant Pages

  • Re: Return code and batch files...
    ... echo first test = %errorlevel% ... echo second test = %errorlevel% ... Copyright Microsoft Corporation. ...
    (microsoft.public.scripting.wsh)
  • Re: Return code and batch files...
    ... echo first test = %errorlevel% ... echo second test = %errorlevel% ...
    (microsoft.public.scripting.wsh)
  • latest PSA result
    ... First Test July 2005 2.1 ... Second Test May 2006 2.7 ... Third Test August 2006 3.7. ... GP refering now me to Urologist as my family history has different cancers ...
    (sci.med.prostate.cancer)
  • How to adapt two tests so they have the same difficulty level?
    ... I am a student of linguistics working on my thesis experiment and I ... have a problem analyzing my data. ... first test - test version A - condition X ... second test - test version B - condition Y ...
    (sci.stat.edu)
  • Re: Jaffers Strokeplay
    ... But after seeing the first test and second test, ... with his stylish / wristy stroke play. ... I feel that he is the most stylish player in this team. ...
    (rec.sport.cricket)