这是我的批处理文件:
ansicon -p
[0;30;4;40mThis is a sentence.[0;1;31;40mThis is a sentence too.
pause
和@echo off
在批处理文件中我只看到:
's not recognized as an internal or external command, operable program or batch file.
和@echo on
我正在看:
C:\Users\Admin\Downloads\Aranesp_injection_reminder\ANSICON>ansicon -p
C:\Users\Admin\Downloads\Aranesp_injection_reminder\ANSICON>This is a sentence.This is a sentence too.
's not recognized as an internal or external command, operable program or batch file.
我究竟做错了什么?
观察:使用0x1b
为了ESC特点。
答案1
使用
0x1b
为了ESC特点。
- 使用ESC保存在变量中
- 在您的批处理文件中:
@echo off
color 0a
for /f skip^=4 %%b in ('"echo;prompt;$E|cmd"')do set "_esc=%%b"
echo/%_esc%[0;30;4;40mThis is a sentence. %_esc%[0;1;31;40mThis is a sentence too
timeout 3 >nul & color f0
- 在您的命令行中:
for /f skip^=4 %b in ('"echo;prompt;$E|cmd"')do @echo\ %b[0;30;4;40mThis is a sentence.%b[0;1;31;40m. This is a sentence too & timeout 3 >nul & color f0