将命令输出分配给变量不起作用

时间:2018-11-06 17:41:56

标签: batch-file cmd

set thisVer="2"
IF EXIST "C:\Program Files\Deployments\deploy.ver" (
    FOR /F "tokens=* USEBACKQ" %%F IN (`type "C:\Program Files\Deployments\deploy.ver"`) DO (
        type "C:\Program Files\Deployments\deploy.ver"
        set build=%%F
    )   
echo "Build version: %build%"
echo "This version: %thisVer%"
IF "%build%"=="%thisVer%" (
    echo "Same Versions"
    exit /B 0
)

上面的代码生成以下输出...

"2"
"Build version:  Files\Deployments\deploy.ver"
"This version: "2""

有人可以告诉我为什么%build%不等于文件C:\ Program Files \ Deployments \ deploy.ver的内容吗?

0 个答案:

没有答案