Why I am getting “Echo is on” when trying to print a variable in batch

后端 未结 1 1620
一个人的身影
一个人的身影 2021-02-04 09:12

I tring to excute a simple batch file scripts :

echo %1
set var = %1
echo %var%

When I am running it in XP, it is giving me expected output, bu

1条回答
  •  情歌与酒
    2021-02-04 09:31

    Get rid of the spaces in your set expression. There can and should be no spaces on either side of the equal sign (=)

    set var=%1
    

    BTW: I usually start all my batch files with @echo off, and end them with @echo on too, so I can avoid mixing code with the output of the batch file. It just makes your batch file output a little nicer and cleaner.

    0 讨论(0)
提交回复
热议问题