使用“goto”命令关闭批处理文件

时间:2014-08-05 01:36:30

标签: batch-file login goto

我的代码还没有完全完成,但它正在工作。现在它在第一部分之后关闭而不是第二部分。我知道这可能是一个愚蠢的错误,但我会很感激帮助!(线条仅适用于组织)

@echo off
title First batch file
color 1f

::-----------------------

----------

:one
cls
echo Please enter your 

name below.
echo.
echo.
set /p name=Name:
echo.
echo.
echo Hello %name%!
echo.
echo.
pause >nul
goto two

::-----------------------

----------

:two
cls
echo Would you like to 

create a new account?
echo (yes or no)
echo.
echo.
set /p yorn=>>
if yorn equ yes then goto 

new
if yorn equ no then goto 

login
pause >nul

::-----------------------

---------

:new
cls
echo Please enter your 

user name.
echo.
echo.
set /p username=Username:
cls
echo.
echo Please enter your 

password.
echo.
echo.
set /p password=Password:
cls
echo.
echo Please confirm your 

password.
echo.
echo.
set /p cpassword=Confirm 

password:
cls
echo.
echo.
if %password% equ 

%cpassword% goto 

confirmscreen
if %password% new 

%cpassword% goto new
pause >nul

:------------------------

---------

:confirmscreen
cls
echo Confirm:
echo.
echo.
echo Username: %username%
echo.
echo Password: %password%
echo.
echo.
set /p yorn2=Yes or No?:
if yorn2 equ yes goto 

login
if yorn2 equ no goto new
pause >nul

:------------------------

---------

1 个答案:

答案 0 :(得分:0)

@echo off
title First batch file
color 1f

::---------------------------------

:one
cls
echo Please enter your name below.
echo.
echo.
set /p name=Name:
echo.
echo.
echo Hello %name%!
echo.
echo.
pause >nul
goto two

::---------------------------------

:two
set /p yorn=Would you like to create a new account? (yes or no) : 
if %yorn% equ yes then goto new
if %yorn% equ no then goto login
goto:two