对不起愚蠢的问题,但我尝试正确地将我的cmd命令转换为批处理命令已经30分钟。我有cmd的工作命令:
"C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\TestComplete.exe" "C:\Users\Administrator\Documents\TestComplete 12 Projects\TestProject1\TestProject1.pjs" /r p:TestProject1 /e
在批处理文件中,我想要变量的渲染路径。例如:
set testCompleteDirectiore_volBat = C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\TestComplete.exe
set testCompleteProjectDirectory_volBat = C:\Users\Administrator\Documents\TestComplete 12 Projects\TestProject1\TestProject1.pjs
set nameProject_volBat = TestProject
call %testCompleteDirectiore_volBat% %testCompleteProjectDirectory_volBat% /r p:%nameProject_volBat% /e
当我尝试运行我的批处理时,我得到例外:
'/r' is not recognized as an internal or external command, operable program or batch file.
当我使用时:
call "C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\TestComplete.exe" "C:\Users\Administrator\Documents\TestComplete 12 Projects\TestProject1\TestProject1.pjs" /r p:TestProject1 /e
所有的工作。我的错误在哪里?
答案 0 :(得分:0)
尝试在'='之前和之后删除赋值运算符中的空格,即 而不是
set var1 = someval1
试
set var1=someval1
答案 1 :(得分:0)
删除=
周围的所有空格等于set
命令,并使用双引号,如下所示:
set "testCompleteDirectiore_volBat=C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\TestComplete.exe"
set "testCompleteProjectDirectory_volBat=C:\Users\Administrator\Documents\TestComplete 12 Projects\TestProject1\TestProject1.pjs"
set "nameProject_volBat=TestProject"
call "%testCompleteDirectiore_volBat%" "%testCompleteProjectDirectory_volBat%" /r p:%nameProject_volBat% /e
其他,=
左侧的空格成为变量名称中的尾随字符,=
右侧的空格成为前导字符变量值,例如
↓
set testCompleteDirectiore_volBat = C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\TestComplete.exe
↑
↓
echo "%testCompleteDirectiore_volBat %"
" C:\Program Files (x86)\SmartBear\TestComplete 12\Bin\TestComplete.exe"
↑