I know that the color bf
command sets the colors of the whole command line window but I wanted to to print one single line in a different color.
相关问题
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
- I want to trace logs using a Macro multi parameter
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- Emacs/xterm color annoyance on Linux
- Compile and build with single command line Java (L
- CosmosDB emulator can't start since port is al
Put the following lines into a file called
ColourText.bas
on your desktop.Save it and type the following in a command prompt.
A file called ColourText.exe will appear on your desktop. Move it to the Windows folder.
To use you must use two character codes to set colour eg
01
not1
.EG To set blue on white by not passing any text, then red on white text, finishing with blue on grey.
or
Also the
CLS
command becomes interesting.Color
command without parameters resets all colours to startup colours.To get the colour code add the following numbers together. Use Calculator in programmers mode. These are hex numbers. They can be added together eg Red + Blue + FG Intensity = 13 = D. As 10+ wasn't used the background will be black. Colour codes MUST be two characters, eg
08
not8
.Use ANSI Escape Sequences.
Windows before 10 - no native support for ANSI colors on the console
For Windows version below 10, the Windows command console doesn't support output coloring by default. You could install either Cmder, ConEmu, ANSICON or Mintty (used by default in GitBash and Cygwin) to add coloring support to your Windows command console.
Windows 10 - Command Line Colors
Starting from Windows 10 the Windows console support ANSI Escape Sequences and some colors by default. The feature shipped with the Threshold 2 Update in Nov 2015.
MSDN Documentation
Demo
Batch Command
The
win10colors.cmd
was written by Michele Locati:To get this working on Windows 10, you can enable this flag:
ENABLE_VIRTUAL_TERMINAL_PROCESSING
.With this registry key you can set this by default
[HKCU\Console] VirtualTerminalLevel dword 0x1
You can just creates files with the name of the word to print, uses findstr which can print in color, and then erases the file. Try this example:
Run
color /?
to get a list of colors.You could use ANSICON to enable ANSI terminal codes in modern Windows. There are 32 and 64 bit versions that I have used in Windows XP and Windows 7.
We used to do this with ANSI terminal codes. Not sure if they still work, but you could try them.