mercredi 29 mai 2019

If statement variable assignment in batch file ignored

I am new to batch file coding and am trying to write a simple If-Else statement.

I have tried to use delayedexpansion as suggested in other questions but still don't seem to get the right value

@echo off
setlocal ENABLEDELAYEDEXPANSION

SET VAR=portrait
IF %VAR% == portrait do (
    SET /a height=1920;
    set /a width=1080;
) else do(
    set /a height=1080;
    set /a width=1920;
)

echo %height%

The code above gives the output as 1080, while I am expecting 1920 based on the logic I wrote. Can someone please help me understand?

Aucun commentaire:

Enregistrer un commentaire