Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法设置变量的值foo。脚本如下:
foo
@echo off set foo = %1 echo %foo%
我将其作为输出:
ECHO is off
谁能告诉我我做错了什么?
删除等号周围的空格:
@echo off set foo=%1 echo %foo%
编辑(详细说明):
你得到ECHO is off是因为%foo%没有设置任何东西,所以命令提示符只会看到ECHO.
%foo%
ECHO
删除set命令中的多余空格:
set
set foo=%1