I am building a .bat that should compare user input with a value. It doesn't go inside the IF "%choice%"=="1" when i test it with an input of 1 or 2.
Here is the batch file :
@echo off
echo Enter '1' to blabla
echo Enter '2' to blabla
echo Enter anything to abort
set /p choice="Type input: "
IF "%choice%"=="1" (
echo toto1
rem save into property file
@echo currentMaster=%ecb%>> MDC.properties
@echo masterDcName=ECBDC>> MDC.properties
@echo currentClone=%bdf%>> MDC.properties
@echo cloneDcName=BDFDC>> MDC.properties
)
IF "%choice%"=="1" (
echo toto2
rem save into property file
@echo currentMaster=%bdf%>> MDC.properties
@echo masterDcName=BDFDC>> MDC.properties
@echo currentClone=%ecb%>> MDC.properties
@echo cloneDcName=ECBDC>> MDC.properties
)
IF NOT "%choice%"=="1" (
echo toto3
IF NOT "%choice%"=="2" (
echo toto4
echo Unknown input ... Aborting script
exit /b 400
)
)
The cmd output :
Enter '1' to blabla
Enter '2' to blabla
Enter anything to abort
Type input: 1
toto3
toto4
Unknown input ... Aborting script
Why is it not going inside the IF "%choice%"=="1" condition ?
Aucun commentaire:
Enregistrer un commentaire