leo60228
leo60228

Reputation: 874

If gives syntax error in Batch

I have the following code in my batch file:

if "%startserver%"=="y"(
    java -Xmx1024M -jar craftbukkit.jar -o true
    exit
)
if "%startserver%"=="n"(
    exit
) else (
    goto invalid
)

It gives the following error when I run it:

The syntax of the command is incorrect.

Upvotes: 1

Views: 126

Answers (1)

Alex
Alex

Reputation: 917

There needs to be a space between the quotes " and the open parenthesis (, like so:

if "%startserver%"=="y" (
    java -Xmx1024M -jar craftbukkit.jar -o true
    exit
)

if "%startserver%"=="n" (
    exit
) else (
    goto invalid
)

Upvotes: 2

Related Questions