NOTE: This is not a duplicate because the other questions I found are not the same goal as mine and is a different if statement
.
I wanted to make a batch file that can remember your name, even after being closed. It saves the name in a text file and then reads from it. My question is it skips past my first if statement
. Why does it do this? When I type y
it goes to :no
. I think this is because right after the if statement
is the :no
part, but what am I doing wrong? If you don't understand this, just copy this code and paste in notepad and then save as ANYTHING.bat
and run it, and you'll see what I mean.
Anyway, here is the code:
@echo off
title The logger
echo NAME> log1.txt
set /p name=<log1.txt
:start
cls
echo Your name is %name%, right? (Y/N)
set /p input=
if %input%=="Y" goto yes
if %input%=="y" goto yes
if %input%=="N" goto no
if %input%=="n" goto no
:no
echo Oh... then what is it?
set /p name=
echo OK! Thanks, %name%
echo %name%>log1.txt
pause
goto start
:yes
echo hahahaha i knew it
echo Would you like to change it? (Y/N)
set /p input=
if %input%=="Y" goto namechange
if %input%=="y" goto namechange
if %input%=="N" (
echo Ok.
pause
goto start
)
if %input%=="n" (
echo Ok.
pause
goto start
)
goto start
:namechange
echo What should it be?
set /p name=
echo %name%>log1.txt
echo Thanks, %name%
pause
goto start
Aucun commentaire:
Enregistrer un commentaire