I'm currently trying to create an installer batch file. At the moment the code is just me trying to work out how the IF statements work. I have not included the code for the installers and such.
I do not know where I am going wrong. When I run the script below, I enter some random text in the hopes that it doesn't reach the code of the first IF statement, but it does. My first IF statement is to check if it is an IP. I typed in "test" but it still runs the code within the first IF statement. It will goto "INSTALL" and then run the code below.
@echo off
:START
SET /P asset=APPLICATION INSTALLER. Please enter IP Address or Asset Number:
CALL IF "%asset:~2,2%"=="2." (
ECHO IP
GOTO INSTALL
) ELSE (
ECHO Selection is not an IP.
GOTO CASSET
)
:CASSET
CALL IF /I NOT "%asset:~0,5%"=="C-" (
ECHO ASSET
SET asset="C-%asset%"
GOTO INSTALL
)
:INSTALL
echo %asset%
cmd /k
pause
:STOP
ECHO Invalid IP or Asset number provided.
pause
What am I doing wrong? Can someone please explain my obvious mistake?
call
in front ofif
!