mardi 6 août 2019

What is wrong with my batch "IF ELSE" example?

I try to run the following code:

@echo off

IF (%4%=="true") (
     echo "First if" 
     powershell.exe -file "installRgExe2.ps1" %1 %2 %3 [] "true"
)
ELSE (
        IF (%5%=="true") (
            echo "Second if"
            powershell.exe -file "installRgExe2.ps1" %1 %2 %3 %4 "true"
        )
        ELSE (
            echo "Last else" 
            powershell.exe -file "installRgExe2.ps1" %1 %2 %3 %4 "false"
        )
)

And I get the error :

'ELSE' is not recognized as an internal or external command,
operable program or batch file.
'ELSE' is not recognized as an internal or external command,
operable program or batch file.

Because of the ELSE errors, the code from the ELSE block is executed, meaning "Last else" is printed...

So....what is wrong in my syntax ?:\

Aucun commentaire:

Enregistrer un commentaire