0

I have this batch file i wrote, and i wrote it to make specific words to be different colors, as a test.

But so far, i can't get any farther than this, I'm stuck, and I was wanting to use it to make other words in different colors, to make a color coding scheme. But can't figure out how. I've honestly spent weeks trying to figure this one out but am having no luck.

Here is my code:

MD Color
CD Color
cls
echo Cool> "Text to Color"
echo Hello> "Test"
echo Test> "Helloo"
cls
FINDSTR /A:0c /C:"Cool" /S "Text to Color"
FINDSTR /A:0b /C:"Hello" /S "Test"
FINDSTR /A:0a /C:"Test" /S "Helloo"
CD..
RD /S /Q Color
@pause

The name of the file is "Text to Color.bat" in a folder named "Color"

Result

C:\Users\CST27\Dropbox\Color\Color>FINDSTR /A:0c /C:"Cool" /S "Text to Color"
Text to Color:Cool

C:\Users\CST27\Dropbox\Color\Color>FINDSTR /A:0b /C:"Hello" /S "Test"
Test:Hello

C:\Users\CST27\Dropbox\Color\Color>FINDSTR /A:0a /C:"Test" /S "Helloo"
Helloo:Test

C:\Users\CST27\Dropbox\Color\Color>CD..

C:\Users\CST27\Dropbox\Color>RD /S /Q Color
Press any key to continue . . .

With "text to color" in red, "test" in blue, and "Helloo" in green.

And I was wanting to maybe try and make the words after those in a different color as well.

2 Answers 2

1

Use Windows PowerShell instead of cmd.exe

Write-Host -ForegroundColor Red -Object "Hello";
Write-Host -BackgroundColor Blue -Object "World!";
3
  • Now, can i make a batch file or some type of file that opens in windows powershell?
    – JustinD
    Nov 29, 2012 at 13:24
  • PowerShell commands can be executed in a script, and vice versa. The script contents should be saved to a .ps1 file. There is lots of documentation about how to execute scripts. technet.microsoft.com/en-us/library/ee176949.aspx Nov 29, 2012 at 14:11
  • 1
    Don't give a PS answer when the OP was asking for batch. You wouldn't like that someone answers your java question in pascal, wouldn't you?
    – Deses
    Jun 21, 2018 at 17:37
1

Just add

@echo off

and you will get a result like this-

Text to Color:Cool

Test:Hello

Helloo:Test

Press any key to continue . . .

With "Text to Color:" in red "Test:" in cyan and "Helloo:" in green

And I am grateful to you for uploading your code, Thanks bruh.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .