ERRORLEVEL command with colors?

Asked

Viewed 610 times

3

I created a script bat to tesar some links, to using the command ping with the errorlevel And it’s working perfectly, but I wanted when I didn’t have communication, I mean, don’t drip, it would be another color, like red. If I get communication, that is, if it drips, turns green... someone knows something that can help me?

  • For every solution you try with a batch over the Windows command prompt ("cmd"), there is a 10 times easier way to do the same with Powershell. If you don’t know him, check him out: http://answall.com/a/41957/14584

  • This answer is already on my favorites, because it always helps me http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux

  • Accurate reset for windows , some hint ?

  • Hello. 
 
 This example works: http://stackoverflow.com/a/7926476/1997073
 
 Very good inclusive!

  • See if this question answers your search!

1 answer

2

For commands running on the Linux Terminal the thing seems to be much easier than Windows Prompt.

That one snippet withdrawn of that website:

echo -e "\e[31mHello World\e[0m"

Causes a Hello World to appear written in red.

For Windows Prompt, I’ll let that answer SOEN because, at least for me, they are very complex commands.

I found the second less confusing, but it leaves a temporary file behind, accepts it as best not answer.

If you already have your choice, the definition of the colors to be used is done through two characters in the argument immediately after the term preceded by a colon.

For this parameter each of the two characters represents a color hexadecimal, the first character being for the color of background and the second to the foreground.

And the colors aren’t all that varied. On that website has a well-readable list of valid options.

I hope it helps you :)

  • The command Color suggested to change the color of the entire text terminal, and not just the next(s) line(s) printed(s). So I guess it doesn’t suit the AP. The idea of using the findstr (in the huge SOEN code quoted) is nice, but besides complex/ugly uses something external. And in this case, since you are going to use something external, maybe it is better to use Powershell (suggested in a comment) or a solution like this: http://www.codeproject.com/Articles/17033/Add-Colors-to-Batch-Files

Browser other questions tagged

You are not signed in. Login or sign up in order to post.