Yoni Mayer
Yoni Mayer

Reputation: 1238

batch script: compare string evaluates to false

I want to run a script which takes a parameter.

this is a sample from the script:

SET application=%1

if (%application%=="prod") (echo "production") else (echo "staging")

i run the script like that script.bat prod

but staging is printed to the screen and not production

What am i doing wrong?

Upvotes: 0

Views: 57

Answers (1)

Cédric Julien
Cédric Julien

Reputation: 80761

You should enclose your variable with quotes : " (and remove superfluous () around the condition)

if "%application%"=="prod" (echo "production") else (echo "staging")

Upvotes: 1

Related Questions