程序在某一点退出。 batch/cmd

program quits at a certain point. batch/cmd

sup,我正在制作一个程序,它将用户输入存储在 .txt 文件中(基本上存储密码),之后您可以去检查密码(可能解锁或打开某些东西等) 出于某种原因,当我尝试比较两个密码时,程序以两种方式退出,这就是问题所在,如果你能帮忙,谢谢

这是代码:

@echo off

:start
echo -create (make a password)
echo -check (check a password)
set /p PROGRAM= enter opperation:
goto %PROGRAM%

:create
cls
set /p data= enter data: 
echo %data% > C:\Users\Hp\testfile.txt
echo done!
pause
goto start

:check 
cls 
set /p data2= what is your password? 
for /f "Delims=" %%realdata in (C:\Users\Hp\testfile.txt) do (
set TEXT=%%realdata
)
if %data2%==%TEXT%
(
pause
goto correct
)
echo wrong, try again
pause
goto start


:correct
echo good job
pause
goto start

尝试改变这个:

if %data2%==%TEXT%
(
pause
goto correct
)

对此:

if %data2% == %TEXT% (
  pause
  goto correct
)

如果不起作用,请尝试更改此设置:

for /f "Delims=" %%realdata in (C:\Users\Hp\testfile.txt) do (
set TEXT=%%realdata
)

对此:

set tmp=<C:\Users\Hp\testfile.txt
set /p password=Enter password: 
if %tmp% == %password% (
  ::something eg. echo PASSWORD is Good!
) ELSE (
  ::Something
)

祝你好运!