Wscript.quit and ErrorLevel on 9x batch file 
Author Message
 Wscript.quit and ErrorLevel on 9x batch file

So does anyone have an answer as to why the errorlevel returned by WSH 5.1
is not soaked up by the environment of a batch file on Win9X?

If I do a Wscript.Quit(44) the batch file testing for the resulting
errorlevel (exit code) is empty.?? wasssuup with dat?



Fri, 17 Oct 2003 12:33:20 GMT  
 Wscript.quit and ErrorLevel on 9x batch file
In a vbs-file just use:

WScript.Quit 44

to quit the script and return an exit code. It works for me.

G. Born

--
______________________________________
Check out the WSH Bazaar at www.borncity.de



Quote:
> So does anyone have an answer as to why the errorlevel returned by WSH 5.1
> is not soaked up by the environment of a batch file on Win9X?

> If I do a Wscript.Quit(44) the batch file testing for the resulting
> errorlevel (exit code) is empty.?? wasssuup with dat?



Fri, 17 Oct 2003 13:17:31 GMT  
 Wscript.quit and ErrorLevel on 9x batch file
My testing with Win 98 SE shows that the errorlevel is correctly
returned ONLY when the Cscript.exe host is used to run the script (which
is what I expected).  When Wscript.exe is used as the host (from a
command prompt), the errorlevel is not available to the MSDOS session.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Quote:

> In a vbs-file just use:

> WScript.Quit 44

> to quit the script and return an exit code. It works for me.

> G. Born

> --
> ______________________________________
> Check out the WSH Bazaar at www.borncity.de



> > So does anyone have an answer as to why the errorlevel returned by
> > WSH 5.1 is not soaked up by the environment of a batch file on
> > Win9X?

> > If I do a Wscript.Quit(44) the batch file testing for the
> > resulting errorlevel (exit code) is empty.?? wasssuup with dat?



Fri, 17 Oct 2003 21:11:56 GMT  
 Wscript.quit and ErrorLevel on 9x batch file
hmmm... Yes I am running it in Cscript :)

Well I am not able to test right now, but I will try it without the ()
around the exit code later today.

Thanks guys!
Shawn


Quote:
> My testing with Win 98 SE shows that the errorlevel is correctly
> returned ONLY when the Cscript.exe host is used to run the script (which
> is what I expected).  When Wscript.exe is used as the host (from a
> command prompt), the errorlevel is not available to the MSDOS session.

> Tom Lavedas
> -----------
> http://www.pressroom.com/~tglbatch/


> > In a vbs-file just use:

> > WScript.Quit 44

> > to quit the script and return an exit code. It works for me.

> > G. Born

> > --
> > ______________________________________
> > Check out the WSH Bazaar at www.borncity.de



> > > So does anyone have an answer as to why the errorlevel returned by
> > > WSH 5.1 is not soaked up by the environment of a batch file on
> > > Win9X?

> > > If I do a Wscript.Quit(44) the batch file testing for the
> > > resulting errorlevel (exit code) is empty.?? wasssuup with dat?



Fri, 17 Oct 2003 23:37:43 GMT  
 Wscript.quit and ErrorLevel on 9x batch file
OK, I am so used to batching in NT/2000 I keep forgetting about Win9X
behaivor. I was doing this which works on NT/2000

TESTS.BAT:
Call cscript test.vbs
Echo the exit code returned was %errorlevel%

TEST.VBS:
Option Explicit
Wscript.Echo "We ran the script"
wscript.Quit (44)

On Win9x this does not work and the errorlevel returned is blank. I have to
test specifically for the errorlevel and I cannot echo it for some reason,
feel free to enlighten me or if anyone has different results please let me
know :) This is using the same VBS file but the batch file is different.

TESTS.BAT:
call CScript test.vbs
IF NOT ERRORLEVEL 1 GOTO DONE
ECHO  An error occurred with exit code 1 or higher.

:DONE
ECHO End of batch file.

Do you guys have the same behaivor?


Quote:
> hmmm... Yes I am running it in Cscript :)

> Well I am not able to test right now, but I will try it without the ()
> around the exit code later today.

> Thanks guys!
> Shawn



> > My testing with Win 98 SE shows that the errorlevel is correctly
> > returned ONLY when the Cscript.exe host is used to run the script (which
> > is what I expected).  When Wscript.exe is used as the host (from a
> > command prompt), the errorlevel is not available to the MSDOS session.

> > Tom Lavedas
> > -----------
> > http://www.pressroom.com/~tglbatch/


> > > In a vbs-file just use:

> > > WScript.Quit 44

> > > to quit the script and return an exit code. It works for me.

> > > G. Born

> > > --
> > > ______________________________________
> > > Check out the WSH Bazaar at www.borncity.de



> > > > So does anyone have an answer as to why the errorlevel returned by
> > > > WSH 5.1 is not soaked up by the environment of a batch file on
> > > > Win9X?

> > > > If I do a Wscript.Quit(44) the batch file testing for the
> > > > resulting errorlevel (exit code) is empty.?? wasssuup with dat?



Sat, 18 Oct 2003 22:38:59 GMT  
 Wscript.quit and ErrorLevel on 9x batch file

Yup, the Win 9x OS does not supply the Errorlevel (nor the OS, Hompage,
UserName ... environment variables).  COMSPEC, PATH, PROMPT, CMDLINE,
windir, winbootdir and TEMP\TMP are all she wrote.

If you want to 'Echo' the errorlevel you can try something like this ...

  for %%v in (0 1 2 3 4 5 6 7 8 9) do if errorlevel  %%v set EL=%%v
  for %%v in (0 1 2 3 4 5 6 7 8 9) do if errorlevel 1%%v set EL=%%v
  echo %EL%

Or for testing purposes, you can try the (undocumented) /Z switch of the
command processor, COMMAND.COM.  It causes the errorlevel to be
displayed after any procedure that (re)set the errorlevel.  Use it for
debugging from a command prompt something like this ...

  %comspec% /z /k

Use the EXIT statement to close the secondary instance of the command
processor.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Quote:

> OK, I am so used to batching in NT/2000 I keep forgetting about
> Win9X behavior. I was doing this which works on NT/2000

> TESTS.BAT:
> Call cscript test.vbs
> Echo the exit code returned was %errorlevel%

> TEST.VBS:
> Option Explicit
> Wscript.Echo "We ran the script"
> wscript.Quit (44)

> On Win9x this does not work and the errorlevel returned is blank. I
> have to test specifically for the errorlevel and I cannot echo it
> for some reason, feel free to enlighten me or if anyone has
> different results please let me know :) This is using the same VBS
> file but the batch file is different.

> TESTS.BAT:
> call CScript test.vbs
> IF NOT ERRORLEVEL 1 GOTO DONE
> ECHO  An error occurred with exit code 1 or higher.

> :DONE
> ECHO End of batch file.

> Do you guys have the same behaivor?



> > hmmm... Yes I am running it in Cscript :)

> > Well I am not able to test right now, but I will try it without the ()
> > around the exit code later today.

{the rest omitted}


Sun, 19 Oct 2003 00:18:55 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Wscript.quit and ERRORLEVEL

2. WScript.Quit Not Setting ErrorLevel Correctly?

3. WScript.Quit is not terminating wscript.exe

4. wscript cant find .vbs file from NT logon batch

5. wscript cant find .vbs file from NT logon batch

6. Problems using WScript to execute a batch file

7. WScript.Quit() problem under WSH 5.1

8. wscript.quit(0)

9. wscript.quit acting strangly - Can you help?

10. WScript.Quit() Problem

11. WSH 2.0 and Include WScript.Quit() BUG?

12. Include with WScript.Quit -> Error

 

 
Powered by phpBB® Forum Software