2017-07-18 71 views
-2
@echo off 
echo. 
echo (backgroundColor_textColor) 
echo set color (Blue_White or Red_White) 
echo. 
set COLOR= 
set /p COLOR = choose color from the color given: 
if "%COLOR%"=="blue_white" goto bw 
if "%COLOR%"=="blue white" goto bw 
if "%COLOR%"=="Blue_White" goto bw 
if "%COLOR%"=="Blue White" goto bw 
if "%COLOR%"=="BW" goto bw 
if "%COLOR%"=="bw" goto bw 
if "%COLOR%"=="red_white" goto rw 
if "%COLOR%"=="red white" goto rw 
if "%COLOR%"=="Red_White" goto rw 
if "%COLOR%"=="Red White" goto rw 
if "%COLOR%"=="RW" goto rw 
if "%COLOR%"=="rw" goto rw 

:bw 
color 1f 
goto start 

:rw 
color 4f 

:start 
pause 
echo. 
pause 
+3

在'设置/ P COLOR =可供选择的颜色given'颜色:去除环境'=空间'。当前写有定义的变量'%COLOR%'(见尾部空格)。把注意力放在'/ I'切换到'if /?'。 – JosefZ

+2

我标记为关闭帖子,因为我们不清楚你在问什么 - 甚至没有问题要回答。 – SteveFest

+0

@SteveFest:嗯,标题中的问题可以这样回答:“打开一个文本编辑器,像记事本,然后输入命令”... **';)** ** – Aacini

回答

1

正如有人在评论中提到的那样,您的问题是set命令中的空格。它应该是这样的:

set /p COLOR=choose color from the color given: 

这里是你的脚本的 “工作” 的版本:

@echo off 
echo. 
echo (backgroundColor_textColor) 
echo set color (Blue_White or Red_White) 
echo. 
set COLOR= 
set /p COLOR=choose color from the color given: 
if "%COLOR%"=="blue_white" goto bw 
if "%COLOR%"=="blue white" goto bw 
if "%COLOR%"=="Blue_White" goto bw 
if "%COLOR%"=="Blue White" goto bw 
if "%COLOR%"=="BW" goto bw 
if "%COLOR%"=="bw" goto bw 
if "%COLOR%"=="red_white" goto rw 
if "%COLOR%"=="red white" goto rw 
if "%COLOR%"=="Red_White" goto rw 
if "%COLOR%"=="Red White" goto rw 
if "%COLOR%"=="RW" goto rw 
if "%COLOR%"=="rw" goto rw 

:bw 
color 1f 
goto start 

:rw 
color 4f 

:start 
pause 
echo. 
pause 
+0

如果可能的话,请在他的评论中加入Aacini所说的一小段 - “SteveFest :那么,标题中的问题可以这样回答:“打开文本编辑器,如记事本,然后键入命令”...;)“。大声笑 – SteveFest

+0

不,谢谢,我回答了这个问题。 –

+0

*您的回复字面上让我发笑,但是*'(我想说以下,但这有点意思,您可以选择阅读或不阅读。整篇文章中唯一的问题是“如何制作此批处理文件颜色选择器?“,所以不会打开一个记事本,ctrl + c的代码,ctrl + v的代码?: - /)' – SteveFest