You might want to know why I need such a script... Well that's my business. Anyway here it is: cls
echo Background color:
echo.
echo 0) Black 8) Gray
echo 1) Blue 9) Light Blue
echo 2) Green A) Light Green
echo 3) Aqua B) Light Aqua
echo 4) Red C) Light Red
echo 5) Purple D) Light Purple
echo 6) Yellow E) Light Yellow
echo 7) White F) Bright White
choice /c 0123456789ABCDEF /n
set ch = %errorlevel%
if %ch% == 1 set bc = 0
if %ch% == 2 set bc = 1
if %ch% == 3 set bc = 2
if %ch% == 4 set bc = 3
if %ch% == 5 set bc = 4
if %ch% == 6 set bc = 5
if %ch% == 7 set bc = 6
if %ch% == 8 set bc = 7
if %ch% == 9 set bc = 8
if %ch% == 10 set bc = 9
if %ch% == 11 set bc = A
if %ch% == 12 set bc = B
if %ch% == 13 set bc = C
if %ch% == 14 set bc = D
if %ch% == 15 set bc = E
if %ch% == 16 set bc = F
cls
echo Text color:
echo.
echo 0) Black 8) Gray
echo 1) Blue 9) Light Blue
echo 2) Green A) Light Green
echo 3) Aqua B) Light Aqua
echo 4) Red C) Light Red
echo 5) Purple D) Light Purple
echo 6) Yellow E) Light Yellow
echo 7) White F) Bright White
choice /c 0123456789ABCDEF /n
set ch = %errorlevel%
if %ch% == 1 set tc = 0
if %ch% == 2 set tc = 1
if %ch% == 3 set tc = 2
if %ch% == 4 set tc = 3
if %ch% == 5 set tc = 4
if %ch% == 6 set tc = 5
if %ch% == 7 set tc = 6
if %ch% == 8 set tc = 7
if %ch% == 9 set tc = 8
if %ch% == 10 set tc = 9
if %ch% == 11 set tc = A
if %ch% == 12 set tc = B
if %ch% == 13 set tc = C
if %ch% == 14 set tc = D
if %ch% == 15 set tc = E
if %ch% == 16 set tc = F
if not %bc% == %tc% (
color %bc%%tc%
) else (
cls
echo Sorry the background color and text color can not be the same!
pause >Nul
)I know it's a little long for such a simple concept but... If you can shorten it with the same outcome then be my guest. (And yes it NEEDS those lines that show the different color choices)
If you wish to see the outcome then copy and paste and add a:
@echo off
Here you go: @echo off :select for %%a in (Background Text) do ( cls echo %%a color: echo. echo 0^) Black 8^) Gray echo 1^) Blue 9^) Light Blue echo 2^) Green A^) Light Green echo 3^) Aqua B^) Light Aqua echo 4^) Red C^) Light Red echo 5^) Purple D^) Light Purple echo 6^) Yellow E^) Light Yellow echo 7^) White F^) Bright White choice /c 0123456789ABCDEF /n call set /a val=%%errorlevel%% - 1 for /f %%b in ('call echo %%val%%') do cmd /c exit /b %%b for /f %%c in ('call echo %%^=exitcode:~-1%%') do set %%a=%%c ) if not "%background%"=="%text%" ( color %background%%text% ) else ( cls echo Sorry the background color and text color can not be the same! pause >Nul goto select ) pause
for /f %%b in ('call echo %%val%%') do cmd /c exit /b %%b for /f %%c in ('call echo %%^=exitcode:~-1%%') do set %%a=%%c
Nice Judago, much cleaner than what I would have done. I think the first FOR here could be replaced with:cmd /c exit /b %%val%%
Thanks Razor2.3, you are correct it can be changed. It didn't even cross my mind. Well here it is changed for bbman225
@echo off
:select
for %%a in (Background Text) do (
cls
echo %%a color:
echo.
echo 0^) Black 8^) Gray
echo 1^) Blue 9^) Light Blue
echo 2^) Green A^) Light Green
echo 3^) Aqua B^) Light Aqua
echo 4^) Red C^) Light Red
echo 5^) Purple D^) Light Purple
echo 6^) Yellow E^) Light Yellow
echo 7^) White F^) Bright White
choice /c 0123456789ABCDEF /n
call set /a val=%%errorlevel%% - 1
cmd /c exit /b %%val%%
for /f %%c in ('call echo %%^=exitcode:~-1%%') do set %%a=%%c
)
if not "%background%"=="%text%" (
color %background%%text%
) else (
cls
echo Sorry the background color and text color can not be the same!
pause >Nul
goto select
)
pause
Thanks works perfectly and much shorter then mine! I also have another script that doesn't work... @echo off :call cls echo Type name of batch file. (without .bat) set /p bat="" if exist "%bat%.bat"( call %bat%.bat ) else ( echo Can not find %bat%.bat pause >nul goto call ) goto callIt's merely supposed to call any batch file that you type in but it keeps giving me "The syntax of the command is incorrect." after i type in the files name.
BTW my question here is still unanswered. Maybe you can help.
@echo off
:call
cls
echo Type name of batch file. (without .bat)
set /p bat=
if exist %bat%.bat (
call %bat%.bat
) else (
echo Can not find %bat%.bat
pause >nul
goto call
)this seems to be working for me.
| « How to figure out how lon... | log out from gmail accoun... » |