China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 00:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 【Original】Beyond the color command - Display colored text in CMD (valid for XP/Vista) View 18,541 Replies 70
Floor 61 Posted 2009-08-23 01:34 ·  中国 浙江 杭州 电信
新手上路
Credits 9
Posts 9
Joined 2009-08-20 11:17
16-year member
UID 150682
Gender Male
Status Offline
Can't output special characters? Even with escape characters, it still can't be output....
Floor 62 Posted 2009-08-26 06:41 ·  中国 北京 中电华通通信有限公司
中级用户
★★
Credits 216
Posts 129
Joined 2007-02-14 07:26
19-year member
UID 79469
Gender Male
Status Offline
xp
Display only once, and will not be displayed for anyone later
Floor 63 Posted 2009-10-24 20:45 ·  中国 广东 广州 鹏博士宽带
高级用户
★★★
Credits 740
Posts 373
Joined 2008-05-23 14:40
18-year member
UID 119498
Gender Male
From 中国,广东
Status Offline
The code on the 1st floor and the 25th floor in the Vista test was completely successful!
别看我是高级用户,其实菜鸟一个,^-^
Floor 64 Posted 2009-10-25 00:42 ·  印度 马哈拉施特拉邦 孟买郊区县 腾讯云
初级用户
Credits 24
Posts 17
Joined 2009-10-07 20:28
16-year member
UID 152733
Gender Male
Status Offline
There are so many codes, it's dizzying to look at.
I uploaded a file, which is much better than the echo command.
http://upload.cn-dos.net/img/1734.rar
Command usage
EchoX 2.5 - (C) 2004-2006 by Bill Stewart (bstewart@iname.com)

Usage: echox ] ] message
or: echox -l

-c Specifies a color (01-FE).
-f, -b Specifies the foreground and background colors (0 through F).
-n Do not skip to the next line.
-w Specifies the message should be 'width' characters wide.
-r Right-aligns the message with respect to the specified width.
-e Centers the message with respect to the specified width.
message The text to be displayed.
-l Lists available colors in a table.

When specifying colors, the foreground color cannot match the background color.
If you specify -c, you cannot specify -f or -b (and vice versa).

The message can contain the following escape sequences: ~n (return), ~r (line
feed), and ~t (tab). To display a literal '~' if it's followed by n, r, or t,
use '~~'. Escape sequences are ignored if -w is specified.
——————————————————————————————————————————
First of all, we can use the -l parameter to see its color coding, and we can type "echox -l" in the command line.
It can be seen that it is the same as the color coding of ColorX above.

The -c parameter specifies the font color and background color. For example, echox -c ce "www.baidu.com" can display the www.baidu.com in yellow on a red background.

The -f and -b parameters specify the font color and background color respectively.

The -n parameter means not to wrap, which is more commonly used in for loops.

The -w parameter means that the specified character is displayed in the width of the command line, and you can directly follow a number representing the width.

The -r and -e parameters respectively mean right alignment and center alignment, and the default is left alignment.

For example: for /l %i in (9,-1,0) do @echox -c %i1 -n -r -w 30 "Www.Baidu.coM"
Friends who are interested can study it more, and can make many interesting things. =_+
Floor 65 Posted 2009-10-31 17:59 ·  中国 天津 电信
初级用户
Credits 40
Posts 37
Joined 2009-06-24 00:38
16-year member
UID 148015
Gender Male
Status Offline
Wuwuwu, can't understand
Floor 66 Posted 2009-10-31 18:04 ·  中国 天津 电信
初级用户
Credits 40
Posts 37
Joined 2009-06-24 00:38
16-year member
UID 148015
Gender Male
Status Offline
How do I feel like I modified the config.nt file? Is it safe?
Floor 67 Posted 2010-05-25 09:57 ·  中国 湖北 襄阳 电信
初级用户
Credits 113
Posts 8
Joined 2003-12-02 00:00
22-year member
UID 13691
Gender Male
Status Offline
Hehe, just supporting purely...
Floor 68 Posted 2010-05-26 02:45 ·  中国 广西 南宁 电信
新手上路
Credits 2
Posts 2
Joined 2010-05-04 15:26
16-year member
UID 166083
Gender Male
Status Offline
Have a try, haha!
Floor 69 Posted 2010-06-01 13:41 ·  中国 上海 奉贤区 电信
新手上路
Credits 7
Posts 7
Joined 2007-04-16 08:33
19-year member
UID 85372
Gender Male
Status Offline
It doesn't work the second time.
Floor 70 Posted 2010-12-23 13:12 ·  中国 江苏 徐州 电信
初级用户
Credits 43
Posts 29
Joined 2008-03-31 15:01
18-year member
UID 114543
Gender Male
Status Offline
Strange situation, sometimes it works sometimes it doesn't...??

I'm in XP environment.

[ Last edited by gudou on 2010-12-23 at 15:51 ]
Floor 71 Posted 2010-12-28 09:27 ·  中国 广东 东莞 中移铁通
初级用户
★★
Credits 115
Posts 92
Joined 2010-12-24 16:57
15-year member
UID 179794
Gender Male
Status Offline
Learning
‹ Prev 1 3 4 5
Forum Jump: