Batch Help -Enter Your Name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Scofield
Posts: 1
Joined: 20 Jun 2014 07:22

Batch Help -Enter Your Name

#1 Post by Scofield » 20 Jun 2014 07:31

Hey, I am fairly new to batch.. so I want a little help. Please don't call me dumb or anything but I am trying to make a enter your name program thing.. but if you enter 'Bob' it goes to a page, but if i enter anything else it goes to that bob page aswell. I might be missing something obvious?


Code: Select all

@echo off 
color 1f
title Don't say Bob!

::###################################

:start
cls
echo Hey there! What's your name? Don't say Bob!
echo.
echo.
set /p bob=Name:
CLS
HEY %BOB% 
echo.
echo.
echo Serious do not say Bob..
if not defined bob (
echo Make a choise!
pause >nul
goto start
)
if %bob%==Bob goto idiot

::######

:idiot
cls
echo YOU
pause >nul
goto start

john924xps
Posts: 65
Joined: 08 Jun 2012 07:48

Re: Batch Help -Enter Your Name

#2 Post by john924xps » 23 Jun 2014 08:34

Batch goes through the program chronologically. In your code, a user with the name "Bob" would be redirected to :idiot, but since you haven't exactly specified what would happen to any other entered name, the program will simply go with the flow and enter into :idiot as well.
The solution you're looking for would be:

Code: Select all

if %bob%==Bob goto idiot ELSE EXIT

Post Reply