goto でジャンプしてしまうと、ジャンプ先のコマンド群を実行した後に戻ってきてくれませんが、call でジャンプすれば、呼び出し位置に戻ってきてくれます。 下記の例では、関数もどきとして、MyFunc1、MyFunc2 を定義し、呼び出しています。 hello.cmd @echo off REM === メインシーケンス call :MyFunc1 call :MyFunc2 exit /b REM === 関数 1 :MyFunc1 echo Hello, I am MyFunc1 exit /b REM === 関数 2 :MyFunc2 echo Hello, I am MyFunc2 exit /b
![バッチファイルでサブルーチンを定義する、別のバッチファイルを呼び出す (call, setlocal) | まくまくWindowsノート](https://cdn-ak-scissors.b.st-hatena.com/image/square/b151782e57ac91cacbed8cd9725e704f4ce089de/height=288;version=1;width=512/https%3A%2F%2Fmaku77.github.io%2Fassets%2Fimg%2Flogo-windows.jpg)