Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am attempting to make a colored command prompt in Windows 7.

Using ansicon, I have successfully managed to create the prompt. However, when I put the commands into a batch file, I receive an error.

These are the commands that I am using:

ansicon -p
chcp 65001
prompt $e[1;31m█$e[1;32m█$e[1;34m█$e[1;33m$_$d $t$_$e[1;37m$p$g

Below is an image that shows the contents and execution of the batch file, and the error that occurs when executing the prompt command within the batch file. It also shows the manual execution of the commands, and the resulting command prompt.

Ansicon batch failure

How can I get the commands to properly execute from a batch file?

share|improve this question
    
Why not just use Powershell. Then you could format the prompt however you wanted in the profile. –  EBGreen Oct 17 '13 at 15:24
    
My guess is that ansicon is failing to hook into the cmd.exe process for the batch file execution. -p What happens when you run ansicon -p on the command line and then run the bat file containing the chcp and prompt commands? ANSICON Documentation –  David Ruhmann Oct 17 '13 at 20:37
    
@EBGreen - I'll give that a try. –  Welton v3.53 Oct 18 '13 at 12:53
    
@DavidRuhmann - Just tried your suggestion, but I still get the same error. –  Welton v3.53 Oct 18 '13 at 12:54

2 Answers 2

I've never used ansicon, and I don't know why your batch script is giving different behavior then the command line.

But give this a try in your batch script:

ansicon -p
chcp 65001
for /f "delims=" %%A in ("$e[1;31m█$e[1;32m█$e[1;34m█$e[1;33m$_$d $t$_$e[1;37m$p$g") do prompt %%A
share|improve this answer
    
I still receive the same error. –  Welton v3.53 Oct 18 '13 at 12:53
up vote 0 down vote accepted

I was unable to get the batch file to work correctly, so I ended up taking @EBGreen's suggestion and using PowerShell. I did have to run the command Set-ExecutionPolicy RemoteSigned in PowerShell to get my profile to run, however.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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