批处理文件 - Abc123不被识别为内部或外部命令

时间:2015-05-08 11:13:47

标签: windows batch-file

我有一个脚本,它使用' set / p'来获取用户输入的详细信息。然后运行一系列命令。

从快捷方式运行脚本时,它工作正常,但是当直接从命令提示符运行时,我得到“Abc123不被识别为内部或外部命令',其中' abc123& #39;是每个' set / p'的用户输入。命令。

如果此时再次按Enter键,它将移至下一个设置/ p'但从不存储价值。

我无法弄清楚这里有什么问题!

1 个答案:

答案 0 :(得分:1)

这里有一个场景可能会充分复制你的问题并给出提示,要么通过"引用"或通过EnableDelayedExpansion

==>30122435.bat

==>set "passw=xyz|abc123"

==>echo quoted  percent "xyz|abc123"
quoted  percent "xyz|abc123"

==>setlocal enabledelayedexpansion

==>echo unquoted exclam. !passw!
unquoted exclam. xyz|abc123

==>echo unquoted percent xyz  | abc123
'abc123' is not recognized as an internal or external command,
operable program or batch file.

==>type 30122435.bat
@ECHO ON
set "passw=xyz|abc123"
echo quoted  percent "%passw%"
setlocal enabledelayedexpansion
echo unquoted exclam. !passw!
echo unquoted percent %passw%

==>