Can anyone explain why this batch file doesn't work correctly?

this is the code: @echo off

ping localhost -n 2

color Fc

echo  Rock, Paper, Scissors!
echo How to play:
echo Type either Rock, Paper or Scissors in the bar and press enter, your opponents
choice will show, and repeat!

set /p %input0%= Enter your choice here :

set /a ran=%random%
if /i %ran% GTR 7 goto :1
if /i %ran% LSS 7 goto :2
if /i %ran% LSS 4 goto :3

if %input0%== Scissors
echo Your opponent chose Rock, Rock beats Scissors, you lost!
echo You Win!
goto Start
if %input0%== Rock
echo You Win!
echo Your opponent chose Paper, Sorry you lose!
goto Start
if %input0%== Paper
echo You Win!
echo Your opponent chose Scissors, Sorry you lose!
goto Start

can someone explain why this doesn't work?

sort by: active | newest | oldest

Another thing to do is move the "LSS 4 " above the "LSS 7". As it stands, you will never go to :3 because any number less than 7, including those less than 4, will go to :2, completely skipping :3.


zomarea225 (author)  Quercus austrina2 years ago


What do you mean "does not work"?

If you get weird errors I suggest to save in a ANSI format, apart from that the LSS and GTR commands are used for numbers, not words.

So you would have to assign a number the choice entered.

You generate a random number between 0 and 32767 to compare with a text input - like comparing apples to bricks ;)

petercd2 years ago

You need another echo in front of choice will show, and repeat! or else it sees choice as a command.

Afterthat it gives a syntax command error, maybe you've left out some subs.

zomarea225 (author) 2 years ago

thanks for the help!