I am running a program which outputs colored text to the Windows command prompt when it runs. Unfortunately, this text is hard to read.

How can I force the output to be black and white? The command in this answer Reset colors on Windows command line (cmd) works well for turning off what the program has already written, but whenever I run it again the colors come back. Basically what I want is to just force my entire session to be B&W.

  • What program are you running that creates colored output? – music2myear Apr 10 at 20:57
  • It's just a Python script that somebody else wrote. I could change the Python code itself but I was wondering if there was an easier way. Also, using "Color 07" has worked well for me because the colors appear a lot better against a black background than my default white, but I'll keep this question up since it's an interesting one. – Stephen Apr 10 at 21:01
  • There is no way that I am aware of to force black and white. If a program has access to the stream then it can put whatever color decorators it wants on the strings that it sends to the stream – EBGreen Apr 10 at 21:05

The best way to do this is to chain the two commands you are using.

<command> && color 07

That way, once the command is run successfully, it will change the color scheme back to black and white.

Otherwise, if you really want any program you run to be displayed in black and white, you can create a batch file to replay this every second:

:loop
 color 07
 timeout /t 1
 goto loop

from cmd /?:

If /D was NOT specified on the command line, then when CMD.EXE starts, it looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if either or both are present, they are executed first.

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

and/or

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

You can add your batch file that changes the color to these registry values to have it executed each time cmd.exe runs without the /D modifier.

This way, your terminal will have it's color reset once every time interval, so It'd be easier to read.

NOTE: This method is very inefficient, and might have a few undesirable side effects.

Sources:

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.