Why this code says echo is off?

前端 未结 5 1847
灰色年华
灰色年华 2021-02-05 01:46

What is wrong with this code? It says ECHO is off.

@ECHO off
set /p pattern=Enter id:
findstr %pattern% .\\a.txt > result
if %errorlevel%==0 (
se         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-05 02:17

    Not sure, if this post is still read, but nevertheless. You should try the following: On top of the code right after @echo off you have to put in

     setlocal enabledelayedexpansion
    

    Additionally anywhere you want to use variables changed in a block of brackets (like For-Loops or If's) you have to change the %into ! to get !varname!

    This should be helping...

    Greetings

    geisterfurz007

提交回复
热议问题