ITコンサルの日常

ITコンサル会社に勤務する普通のITエンジニアの日常です。

コマンドプロンプトcall重要

以下のようなa.bat、b.bat、c.batがあったとする。
■a.bat

@echo off

echo "a.bat start"

call b.bat

echo "a.bat end"

■b.bat

echo "b.bat start"

c.bat

echo "b.bat end"

■c.bat

echo "c.bat start"

echo "c.bat end"

期待結果はこう。

C:\hoge>a
"a.bat start"
"b.bat start"
"c.bat start"
"c.bat end"
"b.bat end"
"a.bat end"

C:\hoge>

が、実際はこうなる。

C:\hoge>a
"a.bat start"
"b.bat start"
"c.bat start"
"c.bat end"
"a.bat end"

C:\hoge>echo %ERRORLEVEL%
0

C:\hoge>

バッチファイルをcallしなかったがために、バッチファイルを呼び出した時点で親バッチファイルは終了となるらしい。にもかかわらず正常終了するのは、ひどいありさまだ。
でも、今日仕事中にやったときは、プロンプト返ってこなかったんだけど、XP HomeとXP Proで違いがあるのかしら?