0

我想知道是否有办法限制批处理文件的循环。我的意思是:假设我有一个脚本:

@echo off
:start
echo Enter the password
set /p password=
if %password%== abcdefg goto correct
if not %password%== abcdefg goto start
:correct
echo good job
timeout 2 > nul
exit
:wrong
echo You are wrong
timeout 1 > nul
exit

说我想让你经历三遍开始,然后你就错了。我该怎么做?

4

1 回答 1

0
@echo off
setlocal enabledelayedexpansion
for /L %%a in (1, 1, 3) do (
set /p "password=Enter the password: "
if "!password!"=="abcdefg" goto :correct
echo You are wrong, try again
timeout /t 1 >nul
)
exit
:correct
echo good job
timeout /t 2 > nul
exit
于 2013-07-22T01:29:11.440 回答