0

I've got a pretty simple batch script, but for some reason the conditional isn't working like I'm expecting:

SET RIG=%1
IF /I RIG==Polar (
    SET SQLSERVER=SQL01
    SET MONITOR=SQL02
    SET TESTSETTING="test"
    SET TESTCONTAINER="test2 
) ELSE ( 
    ECHO Your input was %1.
)

When I pass the following command: testrun.bat Polar I get the ECHO statement returned: Your input was Polar."

I've tried putting the %1 in quotations, messing with the way parentheses are laid out, and I've reviewed ss64.com's syntax for batch script IF statements, but I just can't figure this one out.

2
  • 1
    You need %RIG% not RIGNAME. Commented Oct 6, 2014 at 20:13
  • Just saw that in the answer below. I feel dumb, because I use variables elsewhere in this same script. Commented Oct 6, 2014 at 20:15

1 Answer 1

1

RIGNAME is never going to be equal to Polar

Now you could try assigning the value to rigname rather than rig.

Even then, yu'd need to compare %rigname% to Polar to access the content of rigname rather than the string RIGNAME.

Sign up to request clarification or add additional context in comments.

1 Comment

Holy crap. I use variables all over the place elsewhere in this same script, but somehow missed that. Beautiful, thanks. That makes perfect sense. Also the Rigname/Rig thing was just a typo on my part, in writing this. I'll fix that in the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.