I'm doing a project to help myself learn batch a little better. I have code which is meant to be a "UI" of sorts.
The snippet I have an issue with is this:
:install_check
if exist UI (
echo UI is already installed; reinstall?
CHOICE
if Errorlevel 1 goto :del
if Errorlevel 2 goto :return
cls && goto :install_check
)
goto :install_yes
I know the naming conventions and some of the coding stuff isn't perfect, but I really see no reason why every time it runs it goes to :del
no matter what I type in for choice
.
I've changed the choice
switches and moved it around to be all in one line but it still doesn't want to work. The if
that it is nested in is meant to check if a file is present on the computer, so it is a requirement but also may be the issue?
I tried looking around on this site but nothing will help my issue, any help is gladly accepted!!
Check the errorlevel
s in reverse-order.
if errorlevel n
means if errorlevel
is n or greater
hence, errorlevel
2 will be interpreted as true
for if errorlevel 1