[ 
https://issues.apache.org/jira/browse/GERONIMO-4525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12671759#action_12671759
 ] 

Jack Cai commented on GERONIMO-4525:
------------------------------------

Thanks Jarek for your help!

Ack to 1) & 2).

3) It is because the cmd executing the batch script exits with the exit code of 
the last executied command, not the value of "errorlevel". Take geronimo.bat as 
an example, the last command is "@endlocal", so the exit code will always be 
"0". Calling "cmd /cd exit /b %errorlevel%" will set the exit code properly. 
This is helpful when the batch file is called from a program, for example from 
a Java program (use Runtime.getRuntime().exec()).

Some other comment on your commit -

geronimo.bat
 - better add "cmd /cd exit /b 1" at line 253, to indicate user input errors
 - better add "cmd /cd exit /b 0" at line 309, to reset the errorlevel, because 
some previous calls to "set XXX=" will result in errorlevel 1  :-(

service_pr.bat
 - better add "cmd /cd exit /b 1" at line 167, to indicate user input errors
 - remove unnecessary line 226-234


> No effective exit code for all Windows commands
> -----------------------------------------------
>
>                 Key: GERONIMO-4525
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-4525
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: commands
>    Affects Versions: 2.1.3
>         Environment: MS Windows
>            Reporter: Jack Cai
>            Assignee: Jarek Gawor
>             Fix For: 2.1.4, 2.2
>
>         Attachments: Geronimo-4525_Jack.patch
>
>
> There are multiple problems in the current Windows batch commands (including 
> geronimo.bat, startup.bat, etc.)
>  - It's not recommended to define an environment variable with the name 
> ERRORLEVEL. See [1].
>  - Set a value to ERRORLEVEL has no effect to the exit code of the batch 
> command (so the documented exit code "0" and "1" are not actually there).
>  - The value of the ERRORLEVEL variable will also get unset when the 
> "@endlocal" command is called.
> [1] http://blogs.msdn.com/oldnewthing/archive/2008/09/26/8965755.aspx

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to