Solved if %var% == 1 goto blah isn't working?

January 22, 2012 at 16:01:15
Specs: Windows Vista, Dell Dimension AMD Athlon 64 X2 Dual Core
I have a batch file, and was making an if statement. Then I went in and tested it. It closed, so I got an error log that said 'goto was unexpected at this time.' It was working before, and the other if statements still work, why would this particular one not work?

This is the non-working command: if %luck% == 1 goto lucky
This is the working command: if %svgnum% == back goto mainmenu
They are about the same, besides the variables.

See More: if %var% == 1 goto blah isnt working?

Report •

January 22, 2012 at 23:58:31
✔ Best Answer
Honestly all I can say is syntax's in batch are very sensitive,
the smallest difference in code can mess with a lot of different parts of your batch.

I see no problem, but from my own experience I've had a batch function wrong because of spaces in the statement.

Instead of using:
if %luck% == 1 goto lucky

if %luck%==1 goto lucky

Also make sure that there is a :lucky for the batch to goto.

Report •
Related Solutions

Ask Question