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-08-04 13:13
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Can set /p var= have green prompt text, and the entered text be red? View 1,195 Replies 7
Original Poster Posted 2007-04-15 22:10 ·  中国 广东 汕头 电信
初级用户
Credits 57
Posts 23
Joined 2007-04-02 04:52
19-year member
UID 83682
Gender Male
Status Offline
Can set /p var= make the prompt text green, and the text entered by the user red?

For example: Please enter the date:20070101
Floor 2 Posted 2007-04-15 23:04 ·  中国 江苏 扬州 中移铁通
初级用户
Credits 90
Posts 32
Joined 2007-01-14 09:19
19-year member
UID 76479
Gender Male
Status Offline
colorx program
Floor 3 Posted 2007-04-16 00:06 ·  中国 广东 汕头 电信
初级用户
Credits 57
Posts 23
Joined 2007-04-02 04:52
19-year member
UID 83682
Gender Male
Status Offline
I tried using the echox enhancement tool, but after “set /p var=” the following command gets output as characters.
实用就是好东西!
Floor 4 Posted 2007-04-16 02:14 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
I couldn't think of a way, because this is waiting for user input here.
Floor 5 Posted 2007-04-16 03:01 ·  中国 江苏 盐城 中移铁通
初级用户
Credits 90
Posts 32
Joined 2007-01-14 09:19
19-year member
UID 76479
Gender Male
Status Offline
color foreground is red
set /p var=prompt is empty
echox prompt text (green)
Floor 6 Posted 2007-04-16 03:06 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
Without third-party tools, I'm afraid it's hard to do, right?
Floor 7 Posted 2007-04-16 04:00 ·  中国 浙江 杭州 华数宽带
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
For this kind of thing that's hard to do in batch, it's best to use another language instead.
Floor 8 Posted 2007-05-02 21:40 ·  中国 湖南 联通数据上网公共出口
社区乞丐
★★
gaoshou
Credits -16
Posts 77
Joined 2007-01-30 09:11
19-year member
UID 78105
Gender Male
Status Offline
@echo off
color f2
set/p,=Please enter text:
if "%,%"=="" goto end
color f4
echo %,%
pause>nul
:cool:
Forum Jump: