AW: [Mono-list] Windows: Propagating exit codes in .bat files?

Mike Krueger mike@icsharpcode.net
Mon, 03 May 2004 10:43:54 +0200


Hi

Isn't EXIT a build in commando in the CMD.EXE and COMMAND.COM therefore 
it isn't possible thats not there.
You're right that the Win9x have no /b switch (I've not seen a Win9x 
machine for years :( ). According to some documentation I found in the 
web EXIT exits the command.com in Win9x (like without the /b switch in 
Win2k+).

There is another way which will work on Win9x too ... but it is more a 
hack :

Example:

ECHO %ERRORLEVEL% | CHOICE /C:12345678 /N >NUL

Will set the errorlevel 1-8. But it won't work with negative error 
levels or errorlevels greater or equal than 10. I don't know another 
way, sorry :/

Regards
Mike

>Hi!
>
>Please pay attention: in Win98, there is no /b parameter available.
>A line as EXIT %ERRORLEVEL% exits, but I cannot say if it only exits the batch or the COMMAND.COM (that is the intended usage for the /B parameter in CMD.EXE)
>
>In Win95, the EXIT command might be missing. I haven't tested, but I cannot remember to have seen it.
>
>Another chance for Win9x systems would be to provide .COM files instead of .BAT files. But this would need some knowledge on building .COM files I haven't got.
>
>Jochen
>
>
>-----Ursprüngliche Nachricht-----
>Von: mono-list-admin@lists.ximian.com [mailto:mono-list-admin@lists.ximian.com] Im Auftrag von Mike Krueger
>Gesendet: Sonntag, 2. Mai 2004 21:07
>An: Miguel de Icaza
>Cc: mono-list@ximian.com
>Betreff: Re: [Mono-list] Windows: Propagating exit codes in .bat files?
>
>Hi
>
>try:
>----------
>mono mcs.exe
>exit /b %ERRORLEVEL%
>------------
>
>Regards
>Mike
>
>  
>
>>Hey guys,
>>
>>  We have an issue with Mono, we are shipping batch files for Windows 
>>like this:
>>
>>c:\>type mcs.bat
>>mono mcs.exe
>>c:\>
>>
>>  The problem is that if `mcs.exe' returns an exitcode different than 
>>zero, the error is not propagated to the caller, so this means that in 
>>Makefiles, things keep going even if there is a failure.
>>
>>  Anyone knows enough DOS to tell me how to fix that?
>>
>>Miguel.
>>
>>_______________________________________________
>>Mono-list maillist  -  Mono-list@lists.ximian.com 
>>http://lists.ximian.com/mailman/listinfo/mono-list
>>
>>
>> 
>>
>>    
>>
>
>
>_______________________________________________
>Mono-list maillist  -  Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>_______________________________________________
>Mono-list maillist  -  Mono-list@lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>  
>