I want to use the first argument of my batch script as a variable. If it contains FULL I will set all my variables to 1 and if it's empty I will ask for each.
But I can't make my code work :
@echo off
color 02
::-----------------------------------------
:: Variables
set Preset=%1
set Profile=%2
set NeedToPassTheTests=1
set PublishAPI=0
REM ---------------------
REM We fill the variables depending on the arguments
echo(%1
if defined Preset (
if "%Preset%"=="FULL" (
echo FULL
set PublishOCPP=1
set NeedToPassTheTests=1
set PublishAPI=1
)
) else (
REM No preset so we are going to ask
set /p PublishAPI="Publish API ? (0 or 1).............. ? "
set /p NeedToPassTheTests="Test the projects before ? (0 or 1).............. ? "
)
echo NeedToPassTheTests %NeedToPassTheTests%
echo %PublishAPI%
echo.
pause
I get
The syntax of the command is incorrect
And also my echo at the end are not printing the value (when I remove my ifs) it only displays echo is off.
I'm starting with .bat files, I've tried with only the is Empty test (taken from here : What is the proper way to test if variable is empty in a batch file? ) and it doesn't work either.
Do you know why ?
UPDATE : It works when I pass FULL as argument but my variables are not updated. however it the parameter is empty it doesn't work (ie doesn't ask me to fill the variables).