我对批量编程和编程完全相对较新,但在搜索了几个小时后我发现无济于事,这是我遇到问题的脚本
set /p filename=What is the file name?:
cls
set /p lines=how many lines are there? (one number):
cls
set line=1
:batch_start
for /f "skip=%line% delims=" %%i in (%filename%.txt) do set "ip=%%i"& for /f "tokens=1,2 delims=[]" %%A in ('ping -a %ip% ^| find "Pinging"') do set ip=%%B& if '%lines%'=='%line%' goto done& echo %ip%& set line==%line%+1
pause
:done
echo Done!
pause
请提供帮助,因为代码设置为%ip%并且不执行任何其他操作。
答案 0 :(得分:1)
@echo off
set /p filename=What is the file name?:
cls
set /p lines=how many lines are there? (one number):
cls
set line=1
for /f "skip=%line% delims=" %%i in (%filename%.txt) do set "ip=%%i"
setlocal enableDelayedExpansion
for /f "tokens=1,2 delims=[]" %%A in ('ping -a %ip% ^| find "Pinging"') do (
set ip=%%B
if '%lines%'=='!line!' goto done
echo !ip!
set line==!line!+1
)
pause
:done
echo Done!
pause
这是否按预期工作?