Here's an old trick that works in most MS operating systems.
A writeable %temp% directory is required.
@echo off
type nul>%temp%\~YesOrNo.tmp
echo Would you like to do this now [y/n]?
del /p %temp%\~YesOrNo.tmp>nul
if not exist %temp%\~YesOrNo.tmp goto Yes
Echo Selected "N"
del %temp%\~YesOrNo.tmp
goto end
:Yes Echo Selected "Y"
:end
Another set example:
set answer=no
set/p answer=Do you want to copy to floppy (yes or no)?
if /i "%answer%" EQU "yes" (
copy commands...
) else (
echo.OK, then, I won't copy to floppy.
)
-----------------------------------------------------------------------------
:BEGIN_SCRIPT
ECHO Use of 'SET' demo
ECHO
ECHO Use the Live (online) database?
ECHO 'L' to use the live database
ECHO 'O' to use the offline database
ECHO 'C' to cancel
SET /P USER_TYPED= Whatcha' Wannadoo?
REM Handle both upper and lower case responses.
if %USER_TYPED%==L goto LIVE_DATABASE
if %USER_TYPED%==l goto LIVE_DATABASE
if %USER_TYPED%==O goto OFFLINE_DATABASE
if %USER_TYPED%==o goto OFFLINE_DATABASE
if %USER_TYPED%==C goto CANCEL_SCRIPT
if %USER_TYPED%==c goto CANCEL_SCRIPT
REM If we get here, the choice was not valid
ECHO ERROR: Choice not valid. Please try again
GOTO BEGIN_SCRIPT