vendredi 26 août 2016

every time I try to use one of my features (if/else) it crashes cmd - Batch

so I am creating a test password program and my problem is every time I try to use the create a new password feature it crashes the CMD at the moment I am kinda new to Batch programming so sorry if I over/under codded enter code here

here is the main code that is crashing CMD

:create
cls
if exist C:\Users\%Username%\Documents\Password.txt (
goto password1
) else (
set /p Password=What would you like your new password to be.
echo %Password% > C:\Users\%Username%\Documents\Password.txt
echo your new password is %Password%
pause
goto start
)
:password1
set /p Password1= A password has already been created to change it please  type           the last known password
for /f "Delims=" %%a in (C:\Users\%Username%\Documents\Password.txt) do (
set Text=%%a)
if %Password1%==%Text% goto correct
echo Incorrect!
pause
goto start
:correct
set /p password2=Correct! What would you like your new password to be.
echo %password2% > C:\Users\%Username%\Documents\Password.txt
echo Your new password is %password2%
pause
goto start

here is all the code

@echo off
:start
color a
echo Welcome to the password program with this program you can securely store         personal data,
echo your options for this program are
echo.
echo Create - (Create a new password)
echo.
echo Check - (Check if your password is right)
echo.
 echo Enter - (Enter to check your personal data)
echo.
set /p Program=What would you like to do.
goto %Program%


:create
cls
if exist C:\Users\%Username%\Documents\Password.txt (
goto password1
) else (
set /p Password=What would you like your new password to be.
echo %Password% > C:\Users\%Username%\Documents\Password.txt
echo your new password is %Password%
pause
goto start
)
:password1
set /p Password1= A password has already been created to change it please type    the last known password
for /f "Delims=" %%a in (C:\Users\%Username%\Documents\Password.txt) do (
set Text=%%a)
if %Password1%==%Text% goto correct
echo Incorrect!
pause
goto start
:correct
set /p password2=Correct! What would you like your new password to be.
echo %password2% > C:\Users\%Username%\Documents\Password.txt
echo Your new password is %password2%
pause
goto start

REM Not using this at the moment
:check
cls

REM Not using this at the moment
:enter
cls

sorry if this question has already been answered before I am just new to batch coding

Aucun commentaire:

Enregistrer un commentaire