[Batch] Batch Programming #2: Change Text and Background Color of a Batch Program

Today, we will learn how to change the text and background color of a batch program.

Color Codes of Batch:

0= black     
1= blue       
2= green    
3= apua     
4= red         
5= purple    
6= yellow
7= white
8= gray
9= light blue

Apply Text Color to a Batch file
After typing @echo off (or on), type "color" and follow up with a color code. For example:

@echo off
color 2
echo Hello World!
pause

Results:


Apply Background Color to a Batch file
To set a background color of a batch file, add a color code before the text color code. In the example below, will will have green text and a red background:

@echo off
color 42
echo Hello World!
pause

It means that 4 (red) is the background color and 2 (green) is the text color

Results:


Feel free to ask below if you have any problem
...and don't forget to subscribe --->>

0 comments:

Post a Comment