Windows command background color

Команда COLOR — установить цвет символов и фона консоли Windows

Команда COLOR задает цвет символов и цвет фона в окне консоли .

Формат командной строки:

COLOR [цвет фона][цвет текста]

Цвет задается шестнадцатеричной цифрой, Старший бит определяет яркость, а последующие биты — цвет :

Бит 0 — яркость
Бит 1 — красный ( R )
Бит 2 — зеленый ( G )
Бит 3 — синий ( B )

По умолчанию, используются белые буквы на черном фоне — цвет фона = 0 , цвет символов =7. Значения битов задают комбинацию цветов, так например, для желтого цвета используется установка битов 1 и 2 ( Красный и Зеленый). Команда для установки яркого синего цвета ( 9 ) на желтом фоне ( 6 ) : color 69

То же, но на ярком желтом фоне:

color F0 — черные символы на ярком белом фоне, color 0F — наоборот, белые яркие символы на черном фоне. .

Каждая цифра может иметь следующие значения:

Если в команде COLOR задана только одна цифра, то она определяет цвет символов на черном фоне (значение цвета фона воспринимается как 0 ):

COLOR 1 — синие буквы на черном фоне, как в команде COLOR 01

Если аргумент не указан, команда восстанавливает исходный набор цветов, каким он был на момент запуска CMD.EXE. Этот набор определяется из значения ключа /T, если он был задан при запуске интерпретатора CMD.EXE, или из значения параметров реестра, определяющих пользовательские настройки для интерпретатора команд:

HKEY_LOCAL_MACHINE\ SOFTWARE\ Microsoft \Command Processor\ DefaultColor — для всех пользователей.

HKEY_CURRENT_USER\ Software\ Microsoft\ Command Processor\ DefaultColor — для текущего пользователя. Значения параметров из раздела пользователя более приоритетны, по сравнению с параметрами раздела HKEY_LOCAL_MACHINE

Если параметр DefaultColor имеет значение по умолчанию ( REG_DWORD 0x00000000 ), то цветовой набор определяется значением параметра

HKEY_CURRENT_USER\ Console\ ScreenColors .

Команда COLOR возвращает значение кода ошибки ERRORLEVEL равный 1 при попытке вызова этой команды с совпадающими значениями цвета текста и цвета фона, например — COLOR 00 .

Команда COLOR: меняем цвет текста и фона в командной строке Windows

По умолчанию командная строка Windows располагает чёрным фоном с текстом белого цвета, который располагается на нём. Если такие оформление вам надоело, то, как ни странно, это можно изменить без особых усилий.

Конечно, можно изменить данные настройки через графический интерфейс системы (правой кнопкой мыши по рамке окна командной строкиСвойстваЦвета), но сегодня мы рассмотрим полезную команду COLOR, которая позволяет делать то же самое без дополнительных щелчков мышью.

Изменение цвета текста и фона в командной строке Windows.

Синтаксис команды color очень прост:

Цвета задаются шестнадцатеричными цифрами. Первая цифра отвечает за цвет фона, вторая за цвет текста. Можно использовать следующие цифры:

0 — черный;
1 — синий;
2 — зеленый;
3 — голубой;
4 — красный;
5 — лиловый;
6 — желтый;
7 — белый;
8 — серый;
9 — светло-синий;
A — светло-зеленый;
B — светло-голубой;
C — светло-красный;
D — светло-лиловый;
E — светло-желтый;
F — ярко-белый.

Указав сочетания двух цифр, мы можем задать цвет текста и фона. Например, красный на белом:

Если указать в команде одну цифру, то это будет воспринято как указание цвета текста на чёрном фоне. Например, команда

даст нам светло-зеленый текст на чёрном фоне.

Следует учитывать, что данные настройки будут действовать только пока текущее окно командной строки открыто. Но что делать, если мы хотим сохранить их на постоянной основе? В этом нам помогут два параметра реестра: DefaultColor и ScreenColors.

Для начала посмотрим на DefaultColor. Его можно задать как для отдельного пользователя:

так и для всех пользователей:

Значение параметра из раздела пользователя (HKEY_CURRENT_USER) имеют приоритет над значением параметра для всех.

По умолчанию DefaultColor имеет значение 0x00000000. Это значит, что настройки цвета определяются другим параметром:

Для установки настроек достаточно отредактировать DefaultColor или ScreenColors. Например, мы уже устанавливали красный цвет текста на белом фоне. Вписав подобное значение в реестре, можно установить эту настройку по умолчанию.

Читайте также:  Как открыть порт для ssh linux

Установить одинаковые цвета текста и фона при помощи команды color нельзя. Подобная команда (например, color 55 ) возвратит значение кода ошибки ERRORLEVEL равное 1. Но вот через реестр Windows подобную глупость совершить можно.

Лиловый текст на лиловом фоне в командной строке.

К счастью, и возвратить всё на свои места в случае ошибки не составит труда. Напоминаю, что параметр ScreenColors по умолчанию принимает значение 0x00000007. Это белый текст на чёрном фоне.

COLOR

Sets the default console foreground and background colours.

Colour attributes are specified by 2 of the following hex digits. There should be no space between the two color numbers.

Each digit can be any of the following values:

1 = Blue
9 = Light Blue

2 = Green
A = Light Green

3 = Aqua
B = Light Aqua

4 = Red
C = Light Red

5 = Purple
D = Light Purple

6 = Yellow
E = Light Yellow

7 = White
F = Bright White

If no argument is given, COLOR restores the colour to what it was when CMD.EXE started.

Colour values are assigned in the following order:

The DefaultColor registry value.
The CMD /T command line switch
The current colour settings when cmd was launched

The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute the COLOR command with a foreground and background colour that are the same.

The default terminal color is COLOR 07 , white on black

The COLOR command will change the color of all the text in the window. To change the color of individual words/characters/paragraphs ANSI color escapes can be used. These are available in Windows versions greater than 1511.

New default Color schemes

In Windows 10 clean-install versions greater than build 16257 the default colour scheme has been changed to modernize the look of the Windows Console suitable for modern high-contrast LCD displays.

Samples of the new colors can be found on the ANSI color page, you can also display them with ColorTool.exe -c

If using ColorTool, you may want to tinker with the new values: «So up until very recently the console only supported 16 colours at a time. When the PowerShell team decided they wanted a very specific dark blue as the background colour, rather than altering the colour value for dark or light blue, they instead changed dark magenta to blue and used that as the background colour».

24 bit colors

The new W10 Console also adds full 24-bit color support, this is primarily for Linux compatibility so the console properties page and the default Windows color mappings still use just 16 colors, there is no plan to add additional console colors to the Win32 API.

To take advantage of the new colors use ColorTool.exe and install a theme, or use the VT100 sequences described here.
When the VT100 sequences are used with a version of the Windows Console that supports 24-bit colors they will display the desired RGB color, older consoles will choose the nearest appropriate color from the existing 16 color table.

Errorlevels

If the color was successfully changed %ERRORLEVEL% = 0
Background and foreground colors are the same (will fail) = 1
e.g. COLOR 00

COLOR is an internal command.
If Command Extensions are disabled, the COLOR command will not function.

“How much more black could this be?» and the answer is «None. none more black”

CMD — Start a new CMD shell.
EXIT — Set a specific errorlevel.
How-to: Use ANSI colors in the terminal.
PowerShell: Write-Host — Write output to the screen (colour can be set for individual strings).
Colour codes — HTML/CSS.
Aaron Margosis — Change prompt colors for all Admin level prompts.
Paletton — Design colour themes.
Equivalent bash command (Linux): dircolors — Colour setup for ‘ls’

Command line CMD background change color, but how, with example?

Also during the command input you can change the CMD background color by command and the text, here an example!

The color values ​​can be indicated by two consecutive hexadecimal digits!

1.) Change the background color and foreground color in the CMD!

The first hexadecimal digit defines the background of the prompt,
the second hexadecimal digit defines the foreground, or text color.

You can see the color options by command COLOR /?

Here is an example blue background yellow text! (. see Image-1)

Читайте также:  J2me эмулятор для windows

Tip: The letters can be written small and capitalized.

(Image-1) Command Prompt change background and text!

2.) Change the text and background color of the CMD!

Enter the color command without parameters to reset the color to default. (. see Image-2 Point 1)

(Image-2) Reset background and colors changes!

3.) What should I consider when changing the CMD color?

Attempting to use the same foreground and background color will ignore this command.

Change windows wallpaper from command line

To change windows desktop wallpaper what we normally do is right click on the desktop and go properties and so on. But we can do the same by editing registry key using reg command from command line. The command is given below.

For example to set the image E:\photos\image1.bmp as the wall paper we need to run the command as below.

After editing the registry key we need to run the below command to make the change take effect immediately.

Note that this method works only for bmp images. If you have .jpg or .jpeg images you can’t set them as wallpaper from command line. You can use the Desktop settings UI to set a .jpg or .jpeg file as wallpaper.

This won’t work for two reasons:
1) file needs to be a bmp
2) writing the registry doesn’t cause the change to happen, you need to do something like:

It also works for “.jpg” as well. I’ve tried it. I think the real problems that need to be fix is:
+ remove “/f” from the first command
+ add space after “dll” in the second command

Thanks for the comment..will modify the post with these steps..

Hello, it appears this command does not work for me, I honestly don’t know why…the reason I want to do this is because my windows7 does not have the option to select an image as background when I right click and look at the pop up menu….Any help or suggestions will be appreciate. Thanks

I think you have n’t yet activated your windows copy. Just activate it, after that you can use this.

Try doing it from Control panel -> Appearance and personalization -> Personalization.

Were you trying to do this in RDP connection? Looks like desktop background can’t be changed in remote desktop connections.

My windows7 does not even have this personalization option, siriosly. I am also not using any RDP connection…Any other suggestions? …Is my windows7 screwed up, not installed correctly/fully? Thanks!

you are using wiondows 7 starter! you cannot change backgound picture in windows 7 starter edition

Hello, I wonder why this update thing doesn’t work for me.

The wallpaper is changed in the registry (I checked through regedit.exe) and also in Personalization the new image seems to show up.
But I can’t get it to update immediately.

Thanks in advance.

Looks like the rundll update command is not working in Windows 7. It works in XP. I could not find any other command to make the wall paper changes take effect immediately. However a logoff and login would change the wallpaper.

add a space between dll, Up
rundll32.exe user32.dll, UpdatePerUserSystemParameters

Restarting the computer will fix it.

Forgot to mention, I’m using Window 7 Pro and just locally no remote connections. I want to make this work in a batch script where some conditions are changed 🙂

You can, any command in command prompt will work in batch.

There is two more keys:
1) WallpaperStyle
2) TileWallpaper.
WallpaperStyle = 10 and TileWallpaper = 0 make walpaper filled
WallpaperStyle = 6 and TileWallpaper = 0 make walpaper fited
WallpaperStyle = 2 and TileWallpaper = 0 make walpaper stretched
WallpaperStyle = 0 and TileWallpaper = 0 make walpaper centered
WallpaperStyle = 0 and TileWallpaper = 1 make walpaper tiled

I just tried the command:
“reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d C:\Users\Louis\Desktop\test.bmp /f”

But only get the error:
“ERROR: Invalid key name.
Type “REG ADD /?” for usage.”

Change “HKEY_CURRENT_USER\Control Panel\Desktop”
To “HKCU\Control Panel\Desktop” (You may need to retype out the quotes.

The /f” should not be part of the Quotes for the path to the file to be clearer put the /f before /d and path.

in your example;
reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /f /d “C:\Users\Louis\Desktop\test.bmp”

Читайте также:  Где посмотреть код ошибки синего экрана windows

Hello, I suppose you changed image1.jpg to image1.bmp in the example code after the anonymous comment in January 2011, but you have not made that change in the explanation above the code, it still says image1.jpg.
Thanks for this article anyway, when I searched for a how-to on this topic this was the result which best fitted what I wanted.
And thanks to Keby Zlima for the explanation on the other codes.
Best regards, Bram

Thank you. corrected the explanation.

Before I reached the note that says that the image should be .bmp I was already testing on .jpg which did work for me.

I used that code, it worked great. Once. Now it doesn’t do anything. Thoughts?

I’m trying to get this working for remote support jobs. My plan is to export the existing Desktop hive as a backup, set up my own wallpaper during the session and then, when I’m done, import the saved hive back into place.

Only problem is that (on Win10 at least), the Rundll32 command does nothing. Even after I’ve changed the wallpaper key, F5ing the desktop doesn’t show the new graphic even though it shows up in the registry in the exact same format as if I had edited it through the control panel.

Im using this in a bat file but it won’t work: try reg add /?

It works , Thanks

Thank you so much, you saved me a lot of work to figure out how to make the wallpaper centered and automated.
Chris

It shows me “too many command-line parameters”

For some reason, this only seems to work 5% of the time… Is there any way to make it work “consistently”?

Here’s the code:
reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d %AppData%\Test_image.bmp /f
RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

Note: I made it in a batch file, not directly into cmd, using it to create a program

This batch file solved it for me. It checks if it is before or after 20:00 o’clock. If past – sets night wallpaper if before – sets day wallpaper.
The problem was it sometimes did work at 1st attempt, sometimes after 5th attempt. So I figured it out that the “dll line” should be repeated at least 5 times – now the code works everytime 😀

Add this batch script to your scheduler (at logon and at 20:01) and you will have automagic wallpaper changer based on the time of the day.

@echo off
setlocal enabledelayedexpansion
set “Wtime=!time:

0,2!”
if “!Wtime!” leq “20” reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d “D:\MEGA\Obrazy\Tapety Desktop\mojave_dynamic\mojave_dynamic_8.jpeg” /f & goto done
if “!Wtime!” geq “20” reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d “D:\MEGA\Obrazy\Tapety Desktop\mojave_dynamic\mojave_dynamic_15.jpeg” /f & goto done
:done
timeout /t 5 >nul
start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
endlocal

Win7 Ultimate. What I need to do is not change it but rather *remove* the wallpaper and make it a solid color (black). Does anyone know what the command would be for that? Thanks!

i had some issue in my office i cant change …
it shows like “you can only import binary registry files from within the registry editor”

reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d C:\Users\BRIAFS\Desktop\1.png /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

Powershell command WORKS

Remove the backdrop by going in to Ease of access centre, click Make the computer easier to see, then tick the box Remove background images. You can then change the background colour by going in to Control Panel, Personalisation, Windows Color, and select the Desktop colour

uhh, ive been trying and playing around with this. it hasnt been changing the wallpaper. do i need to restart my computer??

does not work for me on Windows 10, also tried other recommendations.

it don’t work for me when I do like this —-> reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d “C:\Users\Me Lol\Pictures\Wallpaper.png” /f

if you did this on the command Prompt, It don’t work on Windows 10

Оцените статью