这个批处理代码哪里错了?

来源:百度知道 编辑:UC知道 时间:2024/07/12 00:55:45
echo off
setlocal ENABLEEXTENSIONS
:j
for /f "tokens=*" %%n in (ma.txt) do set shu=%%n
set /a shu=%%n+1
if !shu!==4 start
echo !shu!
pause
goto j

ma.txt里的内容是:1

echo off
setlocal enabledelayedexpansion
:j
for /f "tokens=*" %%n in (ma.txt) do (
set shu=%%n
set /a shu=%%n+1
if !shu!==4 start
echo !shu!
)
pause
goto j

***************************
星号以上代码另存为xx.bat测试
setlocal enableextensions是用来打开命令扩展名的,但命令扩展名默认是开启的,你要做的是加一句变量延迟setlocal enabledelayedexpansion。
还是你的需求,我只改了一句,你那个如果shu等于4 start我不知道是想干什么,是你自己要再添加需求吧?

不知道你想要什么效果
do 后面的语句多行的话要用括号
要不变量就是双百分号
你的:j 放在上面 那shu的值永远等于2

"tokens=*"
上面这个不要