自分用メモです。
@echo off
rem #————————————————-
rem # ■キー入力を判定して条件分岐するバッチ Ver.001
rem #————————————————-
rem #————————————————-
rem # ▼キー入力待ち処理
rem #————————————————-
:Main
echo.
echo ▽△▽△▽△▽△▽簡単管理画面▽△▽△▽△▽△▽
echo.
echo キー入力後、エンターで決定して下さい。
echo 処理の開始まで5秒のラグを設けています。
echo.
echo ——————–[MENU]———————-
echo [1]
echo [2]
echo [3]
echo [4]
echo [5]
echo [6]
echo [E] このプログラムを終了する。
echo ————————————————
echo.
set /p input=
if defined input set input=%input:”=%
if /i “%input%” == “1” (goto 処理1)
if /i “%input%” == “2” (goto 処理2)
if /i “%input%” == “3” (goto 処理3)
if /i “%input%” == “4” (goto 処理4)
if /i “%input%” == “5” (goto 処理5)
if /i “%input%” == “6” (goto 処理6)
if /i “%input%” == “E” (goto exit) else goto エラー処理
goto Main
rem #————————————————-
rem # ▼選択したフィルターの配布処理
rem #————————————————-
:処理1
cls
echo 5秒後にメニューに戻ります
ping -n 5 localhost >nul
goto end
:処理2
cls
echo 5秒後にメニューに戻ります
ping -n 5 localhost >nul
goto end
:処理3
cls
echo 5秒後にメニューに戻ります
ping -n 5 localhost >nul
goto end
:処理4
cls
echo 5秒後にメニューに戻ります
ping -n 5 localhost >nul
goto end
:処理5
cls
echo 5秒後にメニューに戻ります
ping -n 5 localhost >nul
goto end
:処理6
cls
echo 5秒後にメニューに戻ります
ping -n 5 localhost >nul
goto end
rem #————————————————-
rem # ▼定義したキー以外を入力した場合のエラー処理
rem #————————————————-
:エラー処理
cls
echo 入力されたキーが違います。
echo.
goto Main
rem #————————————————-
rem # ▼終了処理
rem #————————————————-
:end
echo 処理が完了しました。
echo.
goto Main