Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何批量测试暂停命令上的按钮按下?_Batch File - Fatal编程技术网

Batch file 如何批量测试暂停命令上的按钮按下?

Batch file 如何批量测试暂停命令上的按钮按下?,batch-file,Batch File,我正在编写一个批处理脚本,用户在其中阅读免责声明,然后按任意键继续,或按“E”退出。它看起来像这样: @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 i

我正在编写一个批处理脚本,用户在其中阅读免责声明,然后按任意键继续,或按“E”退出。它看起来像这样:

@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
有没有办法做到这一点?谢谢


为了澄清,我想在他们按E键时退出。我以前见过它,但我忘了它是在哪里看到的。

Choice.exe
按照您的描述执行,但它没有“任意键”选项。您可以指定一个特定的键,如下面的“Y”


和是提示用户输入的两种常用方法,但我认为这两种方法都不会捕获任何键。例如,我认为这两种方法都不会对空间做太多事情。
pause
仅暂停<代码>设置/p等待输入。例如,使用:
set/p id=“Enter input:”
输入“e”并按Enter键,如果id设置为e,则可以设置要转到的标签。@bryc我的意思是,当他们按e键时,我想退出。我以前看过,但我忘了在哪里见过。谢谢,效果很好!。。。除了不能按任何键外,我还添加了更多选项,如“S”以进入设置,因此此解决方案更优越。
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!