Created
January 14, 2017 05:42
-
-
Save danmaq/4044394324057500ac59c5969fae1fc0 to your computer and use it in GitHub Desktop.
This Windows batch file confirm yes or no. If arguments exists, run it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem USAGE: confirm [command: run if confirmed] [args for command] | |
rem ERRORLEVEL: 0: confirmed, 1: declined | |
rem EXAMPLE 1: call confirm | |
rem EXAMPLE 2: confirm msiexec /i foo.msi /qn | |
setlocal | |
echo Are you sure you want to run? [y/N] | |
set /P confirm="" | |
if "%confirm%"=="Y" goto Y | |
if "%confirm%"=="y" goto Y | |
endlocal | |
exit /b 1 | |
:Y | |
endlocal | |
%* | |
exit /b 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment