RuuddR
RuuddR

Reputation: 941

Batch file color changing with menu

So what I want to do is this. When you type a number of a color and then you click return, it goes to another page and then also changes the color to that number. Here is the code I got right now.

@echo off
:Menu
cls
echo 0 = Black
echo 1 = Blue
echo 2 = Green
echo 3 = Aqua
echo 4 = Red
echo 5 = Purple
echo 6 = Yellow
echo 7 = White
echo 8 = Gray
echo 9 = Light Blue
echo A = Light Green
echo B = Light Aqua
echo C = Light Red
echo D = Light Purple
echo E = Light Yellow
echo F = Bright White
set /p Color = Which color do you want?
goto Color

:Color
color %Color%
echo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo Press any button to go back to the menu.
echo you choose %Color%
pause
goto Menu

Why isn't this possible and how is it possible?

Upvotes: 1

Views: 1120

Answers (2)

Johnny Douglas
Johnny Douglas

Reputation: 1

Your setting the word color to a variable , which is the color you enter You need to call the variable as such. In the color prompt enter the background color then the forground color , such as 1E

color %color%

Then watch your screen change color

Upvotes: 0

SachaDee
SachaDee

Reputation: 9545

Your color variable is set as %color % and not as %color% in:

set /p Color = Which color do you want? 

Just remove the space and it will work:

set /p Color= Which color do you want? 

Upvotes: 2

Related Questions