color

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
®ᴱᵴᴲᴙᴠᴱᴆ
Posts: 6
Joined: 23 Aug 2012 10:17

color

#1 Post by ®ᴱᵴᴲᴙᴠᴱᴆ » 23 Aug 2012 12:45

How can you get the default color value of the command prompt?
Do you have to read a registry key?

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: color

#2 Post by abc0502 » 23 Aug 2012 13:59

I guess once you change the color in your cmd from the properities, it will be changed in the registry too.
so you can't get the default values because it's already changed

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: color

#3 Post by Ed Dyreen » 23 Aug 2012 14:02

®ᴱᵴᴲᴙᴠᴱᴆ wrote:How can you get the default color value of the command prompt?
Do you have to read a registry key?
yes

Code: Select all

( %regKey.read_% $var, "HKLM\Software\Microsoft\Command Processor", "DefaultColor" )
( %regKey.read_% $var, "HKCU\Software\Microsoft\Command Processor", "DefaultColor" )

®ᴱᵴᴲᴙᴠᴱᴆ
Posts: 6
Joined: 23 Aug 2012 10:17

Re: color

#4 Post by ®ᴱᵴᴲᴙᴠᴱᴆ » 23 Aug 2012 14:57

Thank you for the responses. When you change the console colors via properties the value still shows up as 0 in the registry. Unless the user has it specified in the registry as 0a, 0b, 0c ..... how do I obtain the hex value of console color not just 0 for default. Where is this data located?

Thanks

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: color

#5 Post by trebor68 » 24 Aug 2012 01:24

I think that the change of properties can find with the following XP command:

Code: Select all

reg query "HKU\.DEFAULT\Console" /v "ScreenColors"

The standard of ScreenColor value is hex07.
background color = 0 = black
text color = 7 = light gray

To reset to standard value in the CMD window:
COLOR
or
COLOR 7
or
COLOR 07

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: color

#6 Post by trebor68 » 24 Aug 2012 15:15

If you run the CMD command with short cut "Win + R" can you use the option "/t" to select the colors.

Without the option "/t" is used the color that is definated in "DefaultColor".

If the value in "DefaultColor" one of the following hex value: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
then is used the "ScreenColors". (background color and text color the same color)

When you use one of the values in COLOR then will not change the color and the ERRORLEVEL 1.

The standard value are:

"HKLM\Software\Microsoft\Command Processor"
DefaultColor=0x00000000 (0)

"HKU\.DEFAULT\Console"
ScreenColors=0x00000007 (7)

###

If you start the CMD command over a link (icon) and you change the properties than will save this possible in the link file.

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: color

#7 Post by Dos_Probie » 26 Aug 2012 18:52

This is what works for me for text color from .reg file...


Code: Select all

;**Customize your dos text color, default is 0 (white) change text to green with the black standard background**
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"DefaultColor"=dword:0000000a

Post Reply