19 May 2015

Command Prompt: Random Colors with a Batch Script

How to have the command prompt text and background change colors with a batch script.
  1. Open a blank Notepad document.
  2. Copy and paste the code at the bottom of this post.
  3. Go to File, then Save As...
  4. Change Save as type to All Files.
  5. Add .bat to the end of the file name.
  6. Save the file to an easy-to-find location, such as the desktop.
  7. Open Command Prompt.
  8. Type cd C:\Users\Name\Desktop or use the file path given in the most recent line of Command Prompt.
  9. Press enter.
  10. Type the name of the .bat file and press enter.
  11. The text and background will randomly change colors.
  12. Use CTRL + C to end the script.
Video: https://www.youtube.com/watch?v=NJ_UudtDZt4

@echo off
set NUM=0 1 2 3 4 5 6 7 8 9 A B C D E F
for %%x in (%NUM%) do (
    for %%y in (%NUM%) do (
        color %%x%%y
        timeout 1 >nul
    )
)