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
This isn't a great answer, but if you know the target workstation has Powershell you can do something like this (assuming BAT / CMD script):
Edit: (now simpler!)
It's an old answer but I figured I'd clarify & simplify a bit
PowerShell is now included in all versions of Windows since 7. Therefore the syntax for this answer can be shortened to a simpler form:
-fore
instead of-foregroundcolor
-back
instead of-backgroundcolor
echo
(rather than creating a separate batch file as above).
Example:
More Information:
The complete list of colors and more information is available in the
- PowerShell Documentation for
Write-Host
You'll need to echo an ANSI escape code sequence to alter the text colour: http://en.wikipedia.org/wiki/ANSI_escape_code
Another very good source of these escape codes is http://ascii-table.com/ansi-escape-sequences.php
This is a self-compiled bat/.net hybrid (should be saved as
.BAT
) that can be used on any system that have installed .net framework (it's a rare thing to see an windows without .NET framework even for the oldest XP/2003 installations) . It uses jscript.net compiler to create an exe capable to print strings with different background/foreground color only for the current line.Here's the help message:
Example:
coloroutput.bat -s "aa\nbb\n\u0025cc" -b 10 -f 3 -n -e
You can also find this script here.
You can also check carlos' color function -> http://www.dostips.com/forum/viewtopic.php?f=3&t=4453
Use the color command. Easy and built in.
Is black and white
Is black and green
I was annoyed by the lack of proper coloring in cmd too, so I went ahead and created cmdcolor. It's just an stdout proxy, which looks for a limited set of ANSI/VT100 control sequences (in other words, like in bash), i.e.
echo \033[31m RED \033[0m DEFAULT | cmdcolor.exe
.Usage and downloads.
you could use cecho.. you can also use it to embed right into your script so you dont have to carry along a .com or .exe
http://www.codeproject.com/Articles/17033/Add-Colors-to-Batch-Files