I am writing a batch script, in which a user reads a disclaimer, then they press any key to continue, or "E" to exit. It looks something like this:
@echo off
echo (some disclaimer text here)
echo.
echo once you fully understand this message, press any key to continue, or press "E" to exit.
::I know that pause doesn't take input, I'm just using it as a placeholder for something
pause>nul
cls
echo Welcome!
pause
Is there any way to accomplish this? Thanks!
To clarify, I want to exit the second they press the E key. I have seen it done before, but I forgot where it saw it.
Choice.exe does what you describe, though it doesn't have an option for "any key". You can specify a specific key such as "Y" below.
echo once you fully understand this message, press "Y" to continue, or press "E" to exit.
choice /c ey
if errorlevel 2 goto :welcome
if errorlevel 1 goto :canceled
rem User pressed Ctrl+C
:canceled
rem User pressed E. Do cancel stuff.
goto :eof
:welcome
rem User pressed Y. Do welcome stuff
echo Welcome!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With