Today is my first time creating a .bat file and I'm finding some odd (for me) problem. Maybe is something basic but as per now I wasn't able to get an answer about why this is happening.
@echo off
:SETPATH
set "installpath="
set /p installpath="Enter path for the installation. Leaving this empty will install this here %CD% "
if not defined installpath set "installpath=%CD%"
if not exist %installpath% (
:CONFIRM
set /P c=Create %installpath% directory [Y/N] ?
if /I "%c%" == "Y" (
md %installpath%
GOTO :INSTALL
)
if /I "%c%" == "N" goto :SETPATH
GOTO :CONFIRM
)
:INSTALL
:: Here goes install proccess
pause
This is simple, as you can see, user needs to prompt a directory where something will be installed later, and in case it doesn't exists, it needs to be created. If the user leaves the input empty, then the thing I want to install installs in the current directory.
When I run the .bat file, I got asked twice to input: Create %installpath% directory [Y/N] ?
The second time I set Y or N, then it continues on.
Can anyone give me light at why this is happening and how to solve it? Thank you!