我需要传递参数行AB CD
从命令行到批处理文件。此参数引用文件名。
如果我使用 AB CD
脚本只选择第一部分并返回 Unable to find the file AB.txt
如果我在我的参数周围加上引号,例如 "AB CD"
我得到的
"AB CD".txt
Illegal characters in path.
最佳答案
您可以使用 %~1 代替 %1
例如一个 test.bat :
echo %~1
然后调用
test "abc de"
将显示:abc de
关于variables - 如何在批处理文件中使用空格传递命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18639663/