user1977050
user1977050

Reputation: 526

windows batch if statement and string comparison

I'm preparing some batch file which contain following code:

set /p NodeType="echo which node type?"
if "%NodeType%" == "HSS"
    (set o2ml=%CURRENT_PATH%\basicData)

While executing this, I'm getting following error:

The syntax of the command is incorrect.

What am I missing?

Upvotes: 0

Views: 118

Answers (3)

konsolebox
konsolebox

Reputation: 75618

You may also not use ():

if "%NodeType%" == "HSS" ^
    set o2ml=%CURRENT_PATH%\basicData

Upvotes: 0

Jeremy Rowler
Jeremy Rowler

Reputation: 387

Try this

set /p NodeType="echo which node type?"
if "%NodeType%" == "HSS" (set o2ml=%CURRENT_PATH%\basicData)

Upvotes: 2

Magoo
Magoo

Reputation: 80213

The opening parenthesis must be on the same physical line as its if

Upvotes: 1

Related Questions