Return code and batch files...
- From: thadfield@xxxxxxxxx
- Date: Mon, 20 Oct 2008 11:56:13 -0700 (PDT)
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?
.
- Follow-Ups:
- Re: Return code and batch files...
- From: Pegasus \(MVP\)
- Re: Return code and batch files...
- Prev by Date: Re: SendKeys Method when Computer is Locked
- Next by Date: Re: Return code and batch files...
- Previous by thread: WSH Failed to Initialize on debug...
- Next by thread: Re: Return code and batch files...
- Index(es):
Relevant Pages
|