需要enabledelayedexpansion
需要清除set /p的内容,不然再次set /p时为空,就是上次的内容- @echo off
- for /f %%i in (testin.txt) do (
- set "aaa=%%i"
- ..\ipmitool.exe xxx(参数)| findstr /c:"Product Serial" >tmp.txt
- setlocal enabledelayedexpansion
- echo,!aaa!>>result.txt
- set /p var=<tmp.txt
- echo,!var!>>result.txt
- echo,>>result.txt
- endlocal
- )
- pause
复制代码
|