Simple SET not working in batch file

狂风中的少年 提交于 2019-12-11 12:47:29

问题


Disclaimer: I'm not a batch files guru, just digging my way with the help of Google and SO. Also note that I'm trying to run this batch file as a Custom Action in SourceTree.

The following simple SET command doesn't seem to assign value to the variable:

SET MYVAR = %1
ECHO "%MYVAR%"
ECHO "!MYVAR!"
ECHO %1 

The first ECHO above returns ""; the second one "!MYVAR!", whereas the last one returns the actual value of command-line parameter. How can I assign value to MVAR?


回答1:


set is sensitive to spaces on each side of the =. You are setting a variable named myvar[Space}



来源:https://stackoverflow.com/questions/36277001/simple-set-not-working-in-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!