Need support for your remote team? Check out our new promo! Select all Open in new window. IT issues often require a personalized solution. Why EE? Get Access. Log In. Web Dev. NET App Servers. We help IT Professionals succeed at work. Batch File: Display lines in a different color. ReneGe asked. Medium Priority.
Last Modified: Hi there, I need to display a specific line in a different color. For example, the following must display both colors at the same time. So when the script pauses, I must see both the red and white lines. I know that the code I used should never do what I need. Start Free Trial. View Solutions Only.
Bill Prew Test your restores, not your backups Experts with Gold status have received one of our highest-level Expert Awards, which recognize experts for their valuable contributions. Expert of the Year This award recognizes experts who help improve Experts Exchange with their contributions to the site, leadership and mentorship efforts, and set an example within the community.
Top Expert This award recognizes someone who has achieved high tech and professional accomplishments as an expert in a specific topic. Commented: However, there are third party typically freeware utilities that can do that, would you like info on those? Let me know if you want an example of that. Not the solution you were looking for?
Getting a personalized solution is easy. Ask the Experts. And some info on the ANSI. SYS escape sequences Author Commented: Hey bp!!
Thanks for your tips. I'll look at them in few minutes Cheers, Rene. Thanks bp, That's exactly what I needed. Both app links are very good.Copy and paste the following code and save it as ncol. Did you use this instructable in your classroom? Add a Teacher Note to share how you incorporated it into your lesson. No its fine, i found a different program that does the same thing but works. I still like ur idea though. Reply 5 years ago on Introduction.
Im making a movement simulator game in batch Kind of like Terraria And for every block is a character or piece of text. I really want to save myself from writing over variables. So is there a way to have arrays in batch? Reply 4 years ago. Hey Pickle! Why don't you create any more instructables?
He used to be the person who fixed all my codes that didn't work and now i have piles of not working code. NCOL is a function, meaning that you need to put in the name ncol and then the arguments. As hard as I try, I can not recreate the issue on my computer. I don't really have any solid ideas as to why it is doing that for you and Mclover, but I will keep trying.
I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says. I want "hi" to be one color, and "world" to be another color.
Actually this can be done without creating a temporary file. The method described by jeb and dbenham will work even with a target file that contains no backspaces. The critical point is that the line recognized by findstr. So the obvious text file to scan with a line not ending with a CRLF is the invoking batch itself, provided that we end it with such a line! Here's an updated example script working this way I'm having a problem with the output of the! Or at least you did not have the same symptoms.
To be investigated. Findstr can be configured to output line numbers or filenames in a defined color. But it has problems with the following strings:. I've modified his technique to something that I think can truly handle any string of printable characters, except for length limitations. Created 2 variants, one takes a string literal, the other the name of a variable containing the string.
The variable version is generally less convenient, but it eliminates some special character escape issues. Backspace does not work across a line break, so the technique can have problems if the line wraps. For example, printing a string with length between 74 - 79 will not work properly if the console has a line width of There has been a lot of development activity at DosTips and SS Below is a version that works on XP and supports ALL single byte characters except 0x00 nul0x0A linefeedand 0x0D carriage return.
However, when running on XP, most control characters will display as dots. I added a :c entry point just for shorthand, and to handle an issue with quote literals. If you have a modern Windows that has powershell installedthe following may work fine as well. Combining dbenham's bird and syntax with skrebbel's powershell write-host methodit seems that powershell can render complex art more quickly than dbenham's pure batch method well, after powershell has been primed once, anyway.
Minimal massaging of the strings are needed, although I haven't tested this with anything other than the bird. If you want a bright green end-of-transmission character for example, you may be out of luck. This method requires echoing out to a temp file, simply because invoking powershell for each call :c takes forever, and it's much faster to queue the output for one powershell invocation.
But it does have the advantage of simplicity and efficiency. Without external tools. BAT that can be used on any system that have installed. It uses jscript. Yes, it is possible with cmdcolor :. You should download chgcolor. Extract both folders to the desktop and copy the executables.
How to change Color of CMD (Command Prompt) Text and Background
Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I have made this script that is supposed to change the color of text depending on how much space your C drive has.
But it only changes to the color mentioned. For example if I put :Red and then :Blueit would only go to red and ignore the blue section. This is the code for my script. Please let me know how to fix it if you can. Learn more. Batch file only showing the first color mentioned Ask Question. Asked 3 days ago.
Add Colors to Batch Files
Active 3 days ago. Viewed 34 times. This program will change colour depending on disk space. For example Compo New contributor. I think you should consider doing the lottery if you are expecting the hard disk space to exactly match a very specific number of bytes. There's a very good chance, the size would be reported, and the console color would turn to cyan before closing, even once if you fix your main issue. Your main issue is that an unquoted variable value is never going to match a quoted series of digits.
Oh OK thanks for letting me know.Tag: batch-file. Can anyone help me with a problem that I am having. I have made a number of scripts that I run with calling the main script Run. Now I haven't done much with batch files before, but I am trying to make a batch file to execute my scripts.
I would like green text is my prompt, so we don't confise it some other prompt. I also would like to get this window get minimized when it pops up. I now I can use this code for that:. And it also works, but then my coloured text is white again because a new command prompt gets opened. Does anyone know how to get my prompt minimized while keeping my coloured letters? You need to use the communicate method for the Popen objects you're creating.
Interesting question. I'm not aware of the size on disk value being a property of any scriptable object. You could calculate it by getting filesize modulo bytes-per-cluster, subtracting that modulo from the file size, then adding the cluster size. Edit: or use Aacini's more efficient calculation, which I'm still trying Now we want If it does not find the program it echoes Yes you can do it in batch.
An example isn't coming to mind in order to help you but since you are running java commands anyway you can do it through java too. Here is an example of how you can be running the commands on CMD from java.
I suspect you have problems with it because it has Unix line endings instead of DOS style line endings. For instance, to replace all. I know you are looking for help with your batch file, but I wanted to show the equivalent powershell solution.Note: The software discussed here is no longer in common use at IU, and UITS may no longer be able to verify this text's accuracy; additionally, the UITS Support Center may no longer have the materials needed to adequately support this software.
Place the following special codes in the text string to produce special information or characters:. This produces a prompt that consists of the current drive and path followed by a greater-than sign. BAT file, located in the root directory. If you wish to produce text of different colors, you will need to install the ANSI screen driver. Make sure that the file ANSI. SYS file, similar to the following:. The above example assumes that the ANSI. Note: ANSI.
DEV may also work, but may be incompatible with some software. You can change the colors of the text in the DOS prompt and the color attributes of the screen using the following escape sequence:. Including color specifications in the prompt command changes not only the color of the prompt, but also the color of other text that you type or display.
In the above example, the prompt will appear red, but other text will show up as yellow on blue. BAT file one of the following command lines that begin with the prompt command:.Change CMD line windows text color (As well as batch files)
This is document aamm in the Knowledge Base. Last modified on Skip to: content search login. Knowledge Base Search. Log in. Options Help Chat with a consultant. Include archived documents. This content has been archivedand is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable. Contact us.Batch files are useful to deal with repetitive tasks.
However, they lack some user-friendly features such as colorizing console outputs.
Colorized outputs might be useful to draw attention to important information. The last section explains how to embed the cecho utility into a batch file using the Debug. Changes log: in cecho v2. Colorizing console output is pretty straightforward. All further console outputs will be displayed in the specified color. We'll explain tokStack later. According to the cecho documentation, parsing command arguments can be described by the following parse tree:.
The parser state chart contains 7 states. The Grammar array stores lists of expected tokens that trigger a transition for a specific state.
An empty list acts as the wild char token. The Action array maintains pointers to the function to execute during a specific transition. The Successor array identifies the next state for each transition. The parser engine iterates through all input characters. If the character triggers an outgoing transition of the current parser state, then the character is added to the tokStack token stack, the action associated with the transition if any is executed, and the parser state is updated.
Note : Debug. I keep this section for reference, but I no longer recommend using it. The embedding mechanism relies on the Debug. EXE utility by Anthony Caruso. The debug script is then embedded in the batch file.
At run time, the debug script is processed by Debug.