Wrong Color of texts [SOLVED]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Wrong Color of texts [SOLVED]

#1 Post by DOSadnie » 06 Aug 2023 16:08

The

Code: Select all

color /?
stipulates usage of such colors
0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue

A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

But e.g. this script

Code: Select all

@echo off

chcp 65001 >nul

color 05

echo.   TEST
echo.   ████

pause
shows me light yellow text on my background instead of purple on black. And by mine background I mean colors chosen by me at

Properties > Colors > Screen Background > Selected Colors Values
Properties > Colors > Popup Background > Selected Colors Values


for every CMD window I could had evoke - and which are now stored in the Registry at

Code: Select all

[HKEY_CURRENT_USER\Console]

[HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe]

[HKEY_CURRENT_USER\Console\%SystemRoot%_SysWOW64_cmd.exe]

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console]

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console\%SystemRoot%_system32_cmd.exe]

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console\%SystemRoot%_SysWOW64_cmd.exe]

I can for example use

Code: Select all

color 06
to get [the darker] yellow [on also my background] but similar case is with the two reds:

Code: Select all

color 0c
will get me text in Light Red but i.e. the proper color, but

Code: Select all

color 04
shows me apparently Black text


So what happens if I choose

Code: Select all

color 00
?

i.e. the Black. My text is shown with colors chosen by me at

Properties > Colors > Screen Text > Selected Colors Values
Properties > Colors > Popup Text > Selected Colors Values


And what happens if I choose

Code: Select all

color 0e
i.d. the Light Yellow which is wrongly shown when I use

Code: Select all

color 05
as reported by me at the beginning of this post? Well, then I get extra light / pale yellow. So either I am able to utilize 3 yellow colors instead of just 2 or I have correctly 2 yellow colors and 1 gold / light brown



So in overall: what Matrix tomfoolery is happening here?

Is it because at

Properties > Colors >

I did change the default values?

And how do I fix this?



I am using Windows 10 Enterprise 20H2 x64
Last edited by DOSadnie on 20 Aug 2023 12:41, edited 3 times in total.

ShadowThief
Expert
Posts: 1162
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Wrong Color of texts

#2 Post by ShadowThief » 06 Aug 2023 16:47

Correct, the values of the color command are indices of the array of colors that are normally set in the registry, which you've changed in your settings.

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: Wrong Color of texts

#3 Post by DOSadnie » 07 Aug 2023 15:28

Yep
DOSadnie wrote:
06 Aug 2023 16:08
[...]
Is it because at

Properties > Colors >

I did change the default values?
It sure looks like it: after adjusting those values once more for example my 3 yellows are no more- I only have that one legit Light Yellow at my disposal


I have also noticed that if I create an LNK leading to this test BAT from my initial post and select for it

Shortcut > Advanced > Run as Administrator

and execute it then I can really see e.g.

Code: Select all

color 04
i.e. Red text on Black background. But this trick does not seem to work for some other more complicated BAT that I use on a daily basis [and for which I just lost my gold text despite re-choosing it in Properties]


All in the feature of colors for CMD window chosen with a BAT and at

Code: Select all

Properties > Colors >
seems like a total user unfriendly mess


Thus
DOSadnie wrote:
06 Aug 2023 16:08
[...]
how do I fix this?
[...]
Revert to defaults and thus see colors only when induced through a given script on a file-by-file basis? Hence I have to decide which modus operandi I prefer?

But then a question arises: if I will indulge is adjusting colors of my scripts and then decide to include them within e.g. AHK files and publish them- then end AutoHotkey users might get a totally unreadable element of them? And such users not having knowledge in regards to adjusting the BAT parts [or even to coding in general] will probably deem such scripts as unusual garbage?

ShadowThief
Expert
Posts: 1162
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Wrong Color of texts

#4 Post by ShadowThief » 07 Aug 2023 19:42

In my experience, people choosing custom colors in the options is extremely rare (in the thirty-odd years that I've been using a computer, you're the only person I've ever heard of who's actually done it). I wouldn't worry too much about other people changing their colors. Also, it isn't possible to set the foreground and background to the same value with the color command (the interpreter ignores the command when that happens so things like color 00 or color 11 don't work), so the text will always be at least semi-legible.

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: Wrong Color of texts

#5 Post by DOSadnie » 17 Aug 2023 04:34

OK, thank you for your input

As for
DOSadnie wrote:
07 Aug 2023 15:28
[...]
DOSadnie wrote:
06 Aug 2023 16:08
[...]
how do I fix this?
[...]
Revert to defaults
[...]
I guess I would have to wipe out from Registry entries made there by my color adjustments to prove that theory right

Post Reply