在命令提示符中使用变量

Dar*_*zen 4 batch-file command-prompt

我在命令提示符中使用变量时遇到问题.根据环境变量的值,我想在批处理文件中执行一些命令.代码如下:

SET CONFIGURATION=Release

if "CONFIGURATION"=="Release"
(copy c:\python26\test1.py d:\testfiles
copy c:\case.jpg d:\images
)
else
(copy c:\python26\test2.py d:\testfiles
copy c:\debug.jpg d:\images
)
Run Code Online (Sandbox Code Playgroud)

这就是我想要做的.我是新手使用这些脚本.所以我没有太多的信息.请帮我解决一下这个.

jeb*_*jeb 6

批处理文件有一些特殊的语法

所以你的代码应该是这样的

SET CONFIGURATION=Release

if "%CONFIGURATION%"=="Release" (
  copy c:\python26\test1.py d:\testfiles
  copy c:\case.jpg d:\images
) else (
  copy c:\python26\test2.py d:\testfiles
  copy c:\debug.jpg d:\images
)
Run Code Online (Sandbox Code Playgroud)

重要的是,括号在同一行上if,ELSE