Skip to content

Instantly share code, notes, and snippets.

@dnaga392
Created July 26, 2018 07:38
Show Gist options
  • Save dnaga392/1cfcbe91c0b0dff2d9590853440dc321 to your computer and use it in GitHub Desktop.
Save dnaga392/1cfcbe91c0b0dff2d9590853440dc321 to your computer and use it in GitHub Desktop.
(Batch) question batch file with default answer
@echo off
setlocal
:QUESTION
set answer=
set /p answer="Will you execute it? ([y]/n) : %answer%"
if "%answer%"=="" (
echo "default start"
) else if "%answer%"=="y" (
echo "start"
) else if "%answer%"=="n" (
echo "cancel"
exit /b 1
)else (
echo "other key"
goto QUESTION
)
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment