我有下面的.bat片段
echo about to start echoing, Errorlevel=%Errorlevel%
echo. >> ../time.txt
echo Just echod a new line into time.txt, Errorlevel=%Errorlevel%
echo | set/p=start=%time%, >> ../time.txt
echo about to start with emake, Errorlevel=%ERRORLEVEL%产出如下:
about to start echoing, Errorlevel=0
Just echod a new line into time.txt, Errorlevel=0
about to start with emake, Errorlevel=1为什么行echo | set/p=start=%time%, >> ../time.txt要更改%ERRORLVEL%
发布于 2016-06-16 16:34:55
该行将ERRORLEVEL设置为1,因为SET /P失败(将ERRORLEVEL设置为1),而您的set/p=start=%time%,永远不会设置值。第一个=之后的所有内容都被认为是提示符,因此没有变量,并且命令总是“失败”。
我不知道你想用这句话做什么,所以我不能给你一个解决方案。但有一件事你应该知道- SET /P is useless for setting variables if used within a pipe。
https://stackoverflow.com/questions/37863003
复制相似问题